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

Annotate nullability of reference types #582

Merged
merged 59 commits into from
Aug 22, 2020
Merged

Conversation

atifaziz
Copy link
Member

@atifaziz atifaziz commented May 3, 2019

This PR enables the nullable context for the entire project and annotates all reference types with respect to their nullability using nullable references that are being introduced with C# 8.

There are a few cases marked with TODO(nullable) that I had trouble reasoning about.

Merging this PR would mean that the code base will be moved to C# 8. Is it too early to impose?

@atifaziz atifaziz requested review from fsateler, leandromoh and jskeet May 3, 2019 10:00
@atifaziz
Copy link
Member Author

atifaziz commented May 3, 2019

Build is failing on AppVeyor because Visual Studio 2019 image is not yet ready.

@jskeet
Copy link
Contributor

jskeet commented May 3, 2019

I'm unlikely to be able to find time to do this any time soon, I'm afraid - I've got a lot on my plate right now.
However, you might want to grab code from the Noda Time appveyor script: https://github.com/nodatime/nodatime/blob/master/appveyor.yml

@atifaziz
Copy link
Member Author

atifaziz commented May 3, 2019

I'm unlikely to be able to find time to do this any time soon, I'm afraid - I've got a lot on my plate right now.

Don't we all. 😉 I'm not in a big hurry to merge this if you think you'll find some time in a few days. I don't expect it to be a huge effort since all warnings are addressed and tests are passing. There's just a couple of corner cases but which might be just compiler bugs for now unless I've misunderstood something. It would have been great to get quick review from you given your experience with the same for NodaTime. I'll remove you as a reviewer for now but if you'd like to be back on the panel then let me know.

However, you might want to grab code from the Noda Time appveyor script: https://github.com/nodatime/nodatime/blob/master/appveyor.yml

Thanks! Using the Visual Studio 2019 Preview image with 52406ab seems to have done the trick for MSBuild meanwhile though it is still failing due to SDK version mismatch.

@atifaziz atifaziz removed the request for review from jskeet May 3, 2019 11:27
@atifaziz
Copy link
Member Author

@fsateler, @leandromoh I've requested your reviews, but I imagine you might not find time in the coming days. On the other hand, this PR makes sweeping changes that I'd like to merge soon to avoid divergence and merge conflicts; it's also been open for far too long. There should be no behavioural changes so I don't expect introduction of any bugs. That said, I did refactor some code to be more honest in the face of nullability. I will merge this PR by this weekend if I don't hear back on premise that there will always be time to make improvements. If you get round to reviewing the changes at a later time then I'd suggest just dropping your comments here (although that would unusual for a PR that will have been closed) or opening new new PRs to propose your changes/improvements. Needless to say, reviews are equally welcome from everyone else who has contributed or commented on this PR so far.

@atifaziz atifaziz added this to the 3.4.0 milestone Aug 13, 2020
MoreLinq/CountBy.cs Show resolved Hide resolved
@@ -111,11 +111,11 @@ public static IEnumerable<TSource> Pad<TSource>(this IEnumerable<TSource> source
if (source == null) throw new ArgumentNullException(nameof(source));
if (paddingSelector == null) throw new ArgumentNullException(nameof(paddingSelector));
if (width < 0) throw new ArgumentException(null, nameof(width));
return PadImpl(source, width, default, paddingSelector);
return PadImpl(source, width, default!, paddingSelector);
Copy link
Member

Choose a reason for hiding this comment

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

Bummer. Sounds like there will be permanent warts (like null!) then

MoreLinq/Experimental/Await.cs Outdated Show resolved Hide resolved
MoreLinq/EndsWith.cs Outdated Show resolved Hide resolved
MoreLinq/CountBy.cs Show resolved Hide resolved
MoreLinq/Collections/Dictionary.cs Show resolved Hide resolved
MoreLinq/Collections/Dictionary.cs Outdated Show resolved Hide resolved
@atifaziz atifaziz requested a review from fsateler August 16, 2020 10:22
Copy link
Member

@fsateler fsateler left a comment

Choose a reason for hiding this comment

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

LGTM!

@atifaziz atifaziz merged commit 8dec9ca into morelinq:master Aug 22, 2020
@atifaziz atifaziz deleted the nullability branch August 22, 2020 11:01
@atifaziz atifaziz restored the nullability branch August 22, 2020 11:21
@atifaziz atifaziz deleted the nullability branch August 22, 2020 11:27
atifaziz added a commit to atifaziz/MoreLINQ that referenced this pull request Aug 22, 2020
This is a note to credit other contributors of "Annotate nullability
of reference types" (commit 8dec9ca).

git shortlog --summary --email --first-parent 8b7e21b..861585c

    51  Atif Aziz <[email protected]>
     3  Orace <[email protected]>
     5  moh-hassan <[email protected]>

Co-authored-by: Pierre Lando <[email protected]>
Co-authored-by: Mohamed Hassan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants