Skip to content
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

Closed
stephentoub opened this issue Nov 16, 2021 · 3 comments
Closed

Avoid need for pragma warning disables in Regex source generator #61666

stephentoub opened this issue Nov 16, 2021 · 3 comments

Comments

@stephentoub
Copy link
Member

The 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.

@ghost
Copy link

ghost commented Nov 16, 2021

Tagging subscribers to this area: @eerhardt, @dotnet/area-system-text-regularexpressions
See info in area-owners.md if you want to be subscribed.

Issue Details

The 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.

Author: stephentoub
Assignees: -
Labels:

area-System.Text.RegularExpressions

Milestone: 7.0.0

@stephentoub
Copy link
Member Author

The pragma for CS0168 was removed in #62605

@jeffschwMSFT jeffschwMSFT removed the untriaged New issue has not been triaged by the area owner label Jan 11, 2022
@stephentoub
Copy link
Member Author

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.

@ghost ghost locked as resolved and limited conversation to collaborators Apr 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants