Environment: vs 2019 v16.3.1
in c# netstandard2.0 and net451 project, I use c# 8 nulable reference with attributes.
Enable c# 8 in csproj:
<LangVersion>8.0</LangVersion>
<Nullable>enable</Nullable>
In myclass.cs, I use AllowNullAttribute:
class My class {
[AllowNull]
public T MyValue {get;set;}
}
When building the project, I get a compilation error:
CS0246 The type or namespace name 'AllowNullAttribute' could not be found (are you missing a using directive or an assembly reference?) ConsoleApp1 (netstandard2.0)
The documentation Attributes extend type annotations include these types
What is wrong in this code?