-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
IDE0031 false positive when #if DEBUG
is used
#65880
Comments
I guess if your a building a release version then |
@elachlan IDExxxx diagnostics are in dotnet/roslyn, not dotnet/roslyn-analyzers. This is generally by-design, and problems similar to this are applicable to all analyzers, not only IDE0031. (for example, consider a "make method static" analyzer that hits a method that can be made static only under a certain configuration) However, for this specific case, I think a syntactic check for Tagging @mavasani @CyrusNajmabadi for thoughts and for moving to dotnet/roslyn |
@mavasani @CyrusNajmabadi Could you move to dotnet/roslyn, or close if by-design? |
Moving to roslyn, we should check for this case in that fixer and not offer it. |
Analyzer
Diagnostic ID: [IDE0031](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0031:
Use null propagation
Analyzer source
.NET7
Describe the bug
Stumbled upon in dotnet/winforms#7902
The analyzer doesn't take into account
#if DEBUG
statements. Inside visual studio it doesn't suggest a code fix. But in CI build it fails.Steps To Reproduce
Enable the analyzer as a warning or error and build a solution with a null check and a
#if DEBUG
statement.Expected behavior
No build failure.
Actual behavior
Build Failure.
Additional context
This is blocking winforms uptake of the rule.
The text was updated successfully, but these errors were encountered: