Closed jaredpar closed 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.
@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.
Reacting to the C# LDM changes to nullable reference types
notnull
constraint @AlekseyTs (PR https://github.com/dotnet/roslyn/pull/36109)where T: object
is a warning (PR https://github.com/dotnet/roslyn/pull/36109)AllowNull
,DisallowNull
,NotNull
,MaybeNull
,NotNullWhen(bool)
,MaybeNullWhen(bool)
@jcouv @cstonReturnTypeWithAnnotations
inNullableWalker
) (issue https://github.com/dotnet/roslyn/issues/36242)TryGetValue
scenario (PR https://github.com/dotnet/roslyn/pull/36284)IComparable<T>
scenarioInterlocked.CompareExchange
(issue https://github.com/dotnet/roslyn/issues/36911)where T: object
is an error (PR https://github.com/dotnet/roslyn/pull/36269)DoesNotReturn
,DoesNotReturnIf(bool)
(PR https://github.com/dotnet/roslyn/pull/36810)NotNullIfNotNull(string)
(issue https://github.com/dotnet/roslyn/issues/31549)