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
base: main
Are you sure you want to change the base?
fix lost diagnostics #52715
Conversation
Please include a test for the scenario being addressed. For a pattern test, perhaps add to |
@@ -1035,7 +1035,7 @@ private void EnforceDoesNotReturn(SyntaxNode? syntaxOpt) | |||
// 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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
…sticsNullableWalker
Debug.Assert(ErrorFacts.NullableWarnings.Contains(MessageProvider.Instance.GetIdForErrorCode((int)errorCode))); This reverts commit 04ffc99.
fixes: #52714