-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Enable nullable on Diagnostics and Rewrite middleware #28621
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
Conversation
Tratcher
left a comment
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.
Diagnostics look fine. I'll let Justin review Rewrite 😁.
| ~Microsoft.AspNetCore.Rewrite.RewriteContext.Logger.set -> void | ||
| ~Microsoft.AspNetCore.Rewrite.RewriteContext.StaticFileProvider.get -> Microsoft.Extensions.FileProviders.IFileProvider | ||
| ~Microsoft.AspNetCore.Rewrite.RewriteContext.StaticFileProvider.set -> void | ||
| Microsoft.AspNetCore.Rewrite.RewriteContext.HttpContext.get -> Microsoft.AspNetCore.Http.HttpContext! |
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.
Is ~ supposed to be removed here?
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.
Yes. No ~ means it is annotated.
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.
IIRC, ~ means that the signature contains at least one reference type which is not known to be either nullable or non-nullable
| @@ -1,48 +1 @@ | |||
| #nullable enable | |||
| Microsoft.AspNetCore.Builder.DeveloperExceptionPageOptions.FileProvider.get -> Microsoft.Extensions.FileProviders.IFileProvider? | |||
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 think this duplication in PublicAPI files was caused by dotnet/roslyn-analyzers#4584
| @@ -1,18 +1,25 @@ | |||
| // Copyright (c) .NET Foundation. All rights reserved. | |||
| // Copyright (c) .NET Foundation. All rights reserved. | |||
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 encoding changes are concerning
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.
My changes are removing the BOMs which I assume is correct 🤷
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.
C# source files should have a byte order mark. It looks like the repository has an incorrectly-configured .editorconfig file which is causing these changes to appear.
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.
➡️ Filed #28697 to fix this
| } | ||
|
|
||
| return new MatchResults { BackReferences = prevBackReferences, Success = condResult.Success }; | ||
| return new MatchResults(condResult!.Success, prevBackReferences); |
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.
💡 Consider proper argument validation instead of suppression. If conditions is empty when this method is called, a NullReferenceException will be thrown here.
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 looked at the source and this method will only be called if there are conditions, which means there will be a condResult. I've added a Debug.Assert with message to make that explicit.
| if (condResult.Success && trackAllCaptures && prevBackReferences != null) | ||
| { | ||
| prevBackReferences.Add(currentBackReferences); | ||
| prevBackReferences.Add(currentBackReferences!); |
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.
💡 If applicable, consider applying MemberNotNullWhen to condResult.Success, and changing this line to:
| prevBackReferences.Add(currentBackReferences!); | |
| prevBackReferences.Add(condResult.BackReferences); |
Addresses #5680