CS8632 - The annotation for nullable reference types should only be used in code within a ‘#nullable’ annotations context.
I copy/pasted the following code from an example I found on the web to test source generators(but that is not where this post is about today).
Building this code resulted in the following warning:
Do you have any idea why?
Take a look at the ‘Name’ property. Notice the usage of ‘?’. This is part of the introduction of nullable reference types and declares the string as nullable.
Nullable reference types are available beginning with C# 8.0, in code that has opted in to a nullable aware context. This is what the warning message is referring to. We need to enable nullable reference type support in our project.
This can be done by adding <Nullable>enable></Nullable> in our csproj file: