Use new StringSyntax Attribute in .NET 7 to give semantic meaning to strings

FYI… the StringSyntax Attribute is new in .NET 7 and allows us to tell Visual Studio what kind of string (eg. regex, datetime, JSON etc.) we are working with in order to get correct intellisense and highlighting 💪🏻 …

In the example below we can see that Visual Studio has now provided regular expression highlighting in line 4 as the string regex parameter has been marked as StringSyntaxAttribute.Regex on line 7.

The above screen grab comes from Nick Chapsas’s excellent YouTube video “The .NET 7 feature that gives meaning to your Strings” … 👇🏻 …

Leave a Reply

Your email address will not be published. Required fields are marked *