Roslyn: Nullable Reference Type Changes

Created on 20 May 2019  路  6Comments  路  Source: dotnet/roslyn

Reacting to the C# LDM changes to nullable reference types

  • 6/10

    • [x] Support for notnull constraint @AlekseyTs (PR https://github.com/dotnet/roslyn/pull/36109)

    • [x] Use of where T: object is a warning (PR https://github.com/dotnet/roslyn/pull/36109)

    • [ ] Support for AllowNull, DisallowNull, NotNull, MaybeNull, NotNullWhen(bool), MaybeNullWhen(bool) @jcouv @cston



      • [x] basic scenarios (PR https://github.com/dotnet/roslyn/pull/35955)


      • [x] conditional attributes (PR https://github.com/dotnet/roslyn/pull/36172)


      • [x] fix namespace issue (PR https://github.com/dotnet/roslyn/pull/36369)


      • [ ] more scenarios involving return value (search for uses of ReturnTypeWithAnnotations in NullableWalker) (issue https://github.com/dotnet/roslyn/issues/36242)


      • [x] attributes on properties and indexers (PR https://github.com/dotnet/roslyn/pull/36444)


      • [x] attributes on fields


      • [x] attributes on fields implemented incorrectly (issue https://github.com/dotnet/roslyn/issues/36830)


      • [x] enforcing attributes on nullable value types (issue https://github.com/dotnet/roslyn/issues/36009, PR https://github.com/dotnet/roslyn/pull/36263)


      • [x] solve the TryGetValue scenario (PR https://github.com/dotnet/roslyn/pull/36284)



    • [x] Support for older attributes is deleted @jcouv @cston

  • 6/17

    • [x] Metadata format changed (@cston)



      • [x] omit private/internal members (PR https://github.com/dotnet/roslyn/pull/36398)


      • [x] omit trivial value types (PR https://github.com/dotnet/roslyn/pull/36519)


      • [x] optimize the representation with context attribute (PR https://github.com/dotnet/roslyn/pull/36152)



  • 7/10

    • [x] IComparable<T> scenario

    • [x] Support for Interlocked.CompareExchange (issue https://github.com/dotnet/roslyn/issues/36911)

    • [x] Equality support (issue https://github.com/dotnet/roslyn/issues/36591)

    • [x] Use of where T: object is an error (PR https://github.com/dotnet/roslyn/pull/36269)

  • RTW

    • [x] Support for DoesNotReturn, DoesNotReturnIf(bool) (PR https://github.com/dotnet/roslyn/pull/36810)

    • [ ] NotNullIfNotNull(string) (issue https://github.com/dotnet/roslyn/issues/31549)

Area-Compilers New Language Feature - Nullable Reference Types Urgency-Soon

Most helpful comment

From the discussion docs - Open question: would we also need a [DoesNotReturnWhenNull(nameof(parameter))]?

Please add this. I use ThrowNotFoundIfNull(someObject) all through my Web API code and apply this pattern elsewhere. I find it very concise and readable. I am such a fan of this that I am thinking about turning off nullability checks if this is not supported.

All 6 comments

I'm excited about the expressiveness of these nullability attributes!

Are the attributes going to be available somehow to .NET Framework/.NET Standard 2.0 projects? It would be sad to not be able to annotate libraries that have to keep supporting Framework.

@carlreinke The attributes will be included (and used) in Core 3.

That can't the whole story though. For example, most of Roslyn cannot target anything later than netstandard2.0 so long as Visual Studio uses .NET Framework. Yet surely Roslyn will be annotated. How will that work?

From the discussion docs - Open question: would we also need a [DoesNotReturnWhenNull(nameof(parameter))]?

Please add this. I use ThrowNotFoundIfNull(someObject) all through my Web API code and apply this pattern elsewhere. I find it very concise and readable. I am such a fan of this that I am thinking about turning off nullability checks if this is not supported.

@carlreinke you'll be able to create these attributes in your own assemblies in the System.Diagnostics.CodeAnalysis namespace, making them internal as needed.

Closing this issue as the bulk was done already and separate issues track the remaining work/bugs.

Was this page helpful?
0 / 5 - 0 ratings