dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.06k stars 4.04k forks source link

Nullable Reference Type Changes #35816

Closed jaredpar closed 5 years ago

jaredpar commented 5 years ago

Reacting to the C# LDM changes to nullable reference types

carlreinke commented 5 years ago

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.

jcouv commented 5 years ago

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

carlreinke commented 5 years ago

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?

Eirenarch commented 5 years ago

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.

drewnoakes commented 5 years ago

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

jcouv commented 5 years ago

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