-
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
Nullable ref type annotation fixes to analyzer APIs #43023
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,8 +58,8 @@ public sealed override Task RegisterCodeFixesAsync(CodeFixContext context) | |
{ | ||
var diagnostic = context.Diagnostics.First(); | ||
var properties = diagnostic.Properties; | ||
var missingCases = bool.Parse(properties[PopulateSwitchStatementHelpers.MissingCases]); | ||
var missingDefaultCase = bool.Parse(properties[PopulateSwitchStatementHelpers.MissingDefaultCase]); | ||
var missingCases = bool.Parse(properties[PopulateSwitchStatementHelpers.MissingCases]!); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We typically reserve the https://github.com/dotnet/roslyn/blob/master/docs/contributing/Nullable%20Annotations.md There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An assert seems unnecessary here since In reply to: 405655126 [](ancestors = 405655126) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ya. The ! was just to keep the compiler warning quiet so that the original behavior of throwing from bool.Parse would be preserved. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense. Thanks |
||
var missingDefaultCase = bool.Parse(properties[PopulateSwitchStatementHelpers.MissingDefaultCase]!); | ||
|
||
Debug.Assert(missingCases || missingDefaultCase); | ||
|
||
|
@@ -137,8 +137,8 @@ private async Task FixOneDiagnosticAsync( | |
bool addCases, bool addDefaultCase, bool onlyOneDiagnostic, | ||
CancellationToken cancellationToken) | ||
{ | ||
var hasMissingCases = bool.Parse(diagnostic.Properties[PopulateSwitchStatementHelpers.MissingCases]); | ||
var hasMissingDefaultCase = bool.Parse(diagnostic.Properties[PopulateSwitchStatementHelpers.MissingDefaultCase]); | ||
var hasMissingCases = bool.Parse(diagnostic.Properties[PopulateSwitchStatementHelpers.MissingCases]!); | ||
var hasMissingDefaultCase = bool.Parse(diagnostic.Properties[PopulateSwitchStatementHelpers.MissingDefaultCase]!); | ||
|
||
var switchLocation = diagnostic.AdditionalLocations[0]; | ||
var switchNode = switchLocation.FindNode(getInnermostNodeForTie: true, cancellationToken) as TSwitchSyntax; | ||
|
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.
hrmm... who passes null for the value. I'd prefer we attempt to disallow that. If you make this non-null, can you point to any violators?
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.
I don't think we can restrict the values for the property bag to be non-null. I think I have seen some third party analyzers using null as a value for the property bag entry.