You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I guess if your a building a release version then #if DEBUG isn't hit so it causes a positive identification. Would Roslyn understand this context? Should we just add a suppression?
@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 #if might make sense.
In general, skipping the analysis for #ifs might have lots of false negatives, but I don't think this is the case for IDE0031.
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: