Macmade
Macmade

Reputation: 54039

.NET - Which system assemblies are annotated for nullable reference types?

I'm trying to find the status of .NET system assemblies regarding the nullable reference types feature of C# 8.

Non-annotated code, or code written with earlier language versions will be treated as "null-oblivious", meaning the compiler won't generate any warnings regarding nullability.

This is really annoying when it comes to using system assemblies from a nullable enabled context, as there's no way to tell if null-checking is required or not.

Is there any way to check if an assembly is annotated for nullable reference types?

Or is there some official status page about this?

Upvotes: 2

Views: 448

Answers (1)

Rikki Gibson
Rikki Gibson

Reputation: 4347

In VS 16.10, you should be able to see whether nullability was enabled in an external assembly by using go-to-definition on a symbol from that assembly that you're using in your code. If nullability was enabled, you should see #nullable enable at the top of the file. This also appears to work in VS Code when using the latest C# extension.

metadata view of nullable-enabled System.Console

Note that in VS this currently requires disabling "navigation to decompiled sources (experimental)" in Options -> Text Editor -> C# -> Advanced.

As far as a status page--it might help you to look over this issue in the dotnet runtime repo, which outlines when certain system assemblies were nullable-annotated.

Upvotes: 2

Related Questions