-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix nullable annotation on IEnumerator.Current #37969
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
Merged
stephentoub
merged 1 commit into
dotnet:master
from
stephentoub:nullableenumeratorcurrent
Jun 17, 2020
Merged
Fix nullable annotation on IEnumerator.Current #37969
stephentoub
merged 1 commit into
dotnet:master
from
stephentoub:nullableenumeratorcurrent
Jun 17, 2020
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48c1c31 to
bcb05fc
Compare
bcb05fc to
0de0188
Compare
buyaa-n
approved these changes
Jun 16, 2020
Contributor
buyaa-n
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.
Looks great, thanks! Left one optional NIT comment
src/libraries/System.Net.Mail/src/System/Net/Mail/MailWriter.cs
Outdated
Show resolved
Hide resolved
cb08f84 to
165063e
Compare
For the non-generic IEnumerator, we don't have any idea whether the type contains nulls or not. If we're forced to annotate it, `?` is correct, because it says "it's possible this is null" and we can't prove it's not. But that ends up leading to lots of spurious warnings, in particular when enumerating over supplied collections that won't ever contain null, e.g. enumerating a CookieCollection. Since the non-generic IEnumerator is effectively legacy, our best path forward while maintaining correctness and avoiding causing unnecessary warnings is to simply not annotate `IEnumerator.Current` at all, leaving it "oblivious"; in that way, we don't make any claims about its state, and leave it up to tooling how to best convey that.
165063e to
ebbb979
Compare
AndyAyersMS
pushed a commit
to AndyAyersMS/runtime
that referenced
this pull request
Jul 30, 2020
Reworking of dotnet#37969. Block LSRA from using R2 around the profiler leave callback, but don't kill GC refs in R2, since late codegen will use R2 to temporarily hold return values around the callback. Fixes dotnet#37223.
AndyAyersMS
added a commit
that referenced
this pull request
Jul 30, 2020
) Reworking of #37969. Block LSRA from using R2 around the profiler leave callback, but don't kill GC refs in R2, since late codegen will use R2 to temporarily hold return values around the callback. Fixes #37223. Co-authored-by: Carol Eidt <[email protected]>
Jacksondr5
pushed a commit
to Jacksondr5/runtime
that referenced
this pull request
Aug 10, 2020
…net#40123) Reworking of dotnet#37969. Block LSRA from using R2 around the profiler leave callback, but don't kill GC refs in R2, since late codegen will use R2 to temporarily hold return values around the callback. Fixes dotnet#37223. Co-authored-by: Carol Eidt <[email protected]>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For the non-generic IEnumerator, we don't have any idea whether the type contains nulls or not. If we're forced to annotate it,
?is correct, because it says "it's possible this is null" and we can't prove it's not. But that ends up leading to lots of spurious warnings, in particular when enumerating over supplied collections that won't ever contain null, e.g. enumerating a CookieCollection. Since the non-generic IEnumerator is effectively legacy, our best path forward while maintaining correctness and avoiding causing unnecessary warnings is to simply not annotateIEnumerator.Currentat all, leaving it "oblivious"; in that way, we don't make any claims about its state, and leave it up to tooling how to best convey that.Fixes https://github.com/dotnet/csharplang/issues/3214
cc: @buyaa-n