Top
image credit: Adobe Stock

Tagged Strings in Visual Studio and .NET 7

November 21, 2022

Via: InfoQ

As part of .NET 7, developers now have the ability to tag strings using the StringSyntax attribute. These tags inform tools such as Visual Studio as to the nature of the string. For example, you can mark the string as containing JSON or RegEx and Visual Studio will apply the appropriate syntax highlighting.

Also shown in the image above is a code-completion like feature that displays the definition of formatting characters for date/time format strings.

The StringSyntax attribute can be applied to fields, properties, and parameters. The list of built-in syntax types is shown below, but developers can supply their own as well.

Read More on InfoQ