csharpstandard icon indicating copy to clipboard operation
csharpstandard copied to clipboard

[Epic] Specify nullable reference types in C# 8

Open jskeet opened this issue 1 year ago • 4 comments

#700 is a draft which will be useful, but we're going to try to do this in multiple small PRs.

The current planned task list is:

  • [x] #1088
  • [x] #1089
  • [x] #1090
  • [ ] #1091
  • [ ] #1092
  • [ ] #1093
  • [ ] #1094

jskeet avatar Apr 24 '24 21:04 jskeet

Are MaybeNullWhenAttribute and others going to be standardised?

KalleOlaviNiemitalo avatar Apr 26 '24 14:04 KalleOlaviNiemitalo

Are MaybeNullWhenAttribute and others going to be standardised?

Yes, see #1092

BillWagner avatar Apr 26 '24 15:04 BillWagner

Does any of those issues cover how variance of generic parameters should affect warnings about identity conversions:

using System;
public class C {
    // f1 is a delegate that takes string? and returns string.
    public void M(Func<string?, string> f1) {
        // Nullability of type arguments does not match,
        // but there is no warning, because of variance.
        Func<string, string?> f2 = f1;

        // Convert back to the original type.
        // This causes a warning.
        Func<string?, string> f3 = f2;
    }
}

https://github.com/dotnet/csharplang/blob/main/proposals/csharp-9.0/nullable-reference-types-specification.md doesn't seem to mention this.

I'm not sure whether this behaviour is C# 8 or 9, but I guess 8.

KalleOlaviNiemitalo avatar Jun 12 '24 19:06 KalleOlaviNiemitalo

Terminology question: Do we want to use "nullable context" or "null analysis context"? Alternative is "set the flags in the nullable context".

See https://github.com/dotnet/csharpstandard/pull/1123/files#r1672741166

However, note that the null state analysis is always being done. The comment states that the context may impact that.

BillWagner avatar Jul 10 '24 20:07 BillWagner