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

fix lost diagnostics #52715

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ internal static void AnalyzeIfNeeded(
// Once we address https://github.com/dotnet/roslyn/issues/46579 we should also always pass `getFinalNullableState: true` in debug mode.
// We will likely always need to write a 'null' out for the out parameter in this code path, though, because
// we don't want to introduce behavior differences between debug and release builds
Analyze(compilation, method, node, new DiagnosticBag(), useConstructorExitWarnings: false, initialNullableState: null, getFinalNullableState: false, out _, requiresAnalysis: false);
Analyze(compilation, method, node, diagnostics, useConstructorExitWarnings: false, initialNullableState: null, getFinalNullableState: false, out _, requiresAnalysis: false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The call to Analyze() here is only used to test nullable analysis, not for reporting diagnostics. (IsNullableAnalysisEnabledAlways is usually false in RELEASE builds.) The diagnostics here should be dropped.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in #52714 one side effect of this analyze call is that it sees that null is not handled in a switch expression. And a diagnostic is emitted for that.
Perhaps that check should be moved somewhere else?
I encountered that while I wrote a test for switch-expression "IsExhaustive".

But your are right that this change alone is insufficient because the warning I'm looking for is filtered out in CSharpDiagnosticFilter.GetDiagnosticReport

}
finalNullableState = null;
return;
Expand Down