-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Analyzer: Validate literal arguments to StringSyntaxAttribute parameters/members #64009
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to this area: @dotnet/area-system-runtime Issue Details#62995 adds the new StringSyntaxAttribute and annotates a bunch of APIs with it, for the two syntaxes currently identified: Regex and DateTimeFormat. Visual Studio will look for these and use it to influence its colorization, IntelliSense, etc., but we can also use them to help warn developers at dev time / build time when they've written something that will produce run-time failures. We can add an analyzer for each syntax that will warn on the literal provided, e.g. these would warn var r = new Regex("[abc"); // Invalid pattern '[abc' at offset 4. Unterminated [] set.
DateTime.ParseExact(DateTime.Now.ToString(), "c", null); // Invalid format specifier
|
#62995 added the new StringSyntaxAttribute, and we annotated a bunch of APIs with it, for the three syntaxes currently identified: Regex, DateTimeFormat, and Json.
Visual Studio will look for these and use it to influence its colorization, IntelliSense, etc., but we can also use them to help warn developers at dev time / build time when they've written something that will produce run-time failures. We can add an analyzer for each syntax that will warn on the literal provided, e.g. these would warn
The text was updated successfully, but these errors were encountered: