-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Avoid need for pragma warning disables in Regex source generator #61666
Comments
Tagging subscribers to this area: @eerhardt, @dotnet/area-system-text-regularexpressions Issue DetailsThe Regex source generator currently emits this at the beginning of the generated file: #pragma warning disable CS0162 // Unreachable code
#pragma warning disable CS0164 // Unreferenced label
#pragma warning disable CS0168 // Variable declared but never used
#pragma warning disable CS0219 // Variable assigned but never used It would be nice (but not required) to avoid the need for these by changing the code generator to not emit the patterns causing these warnings to fire, e.g. variables that are emitted in case they're needed but sometimes aren't, labels emitted out of convenience but sometimes aren't needed, etc. These shouldn't be a performance issue, as they're weeded out by the C# compiler at build time, but these patterns make the code a bit less readable.
|
The pragma for CS0168 was removed in #62605 |
I'm going to close this. While it'd be nice to remove the three remaining pragmas, it would be difficult to do so well and simply isn't worth it. |
The Regex source generator currently emits this at the beginning of the generated file:
It would be nice (but not required) to avoid the need for these by changing the code generator to not emit the patterns causing these warnings to fire, e.g. variables that are emitted in case they're needed but sometimes aren't, labels emitted out of convenience but sometimes aren't needed, etc. These shouldn't be a performance issue, as they're weeded out by the C# compiler at build time, but these patterns make the code a bit less readable.
The text was updated successfully, but these errors were encountered: