环境:vs 2019 v16.3.1
在c#netstandard2.0和net451项目中,我使用带有属性的c#8可空引用。
在csproj中启用c#8:
<LangVersion>8.0</LangVersion>
<Nullable>enable</Nullable>
在myclass.cs中,我使用AllowNullAttribute:
class My class {
[AllowNull]
public T MyValue {get;set;}
}
构建项目时,出现编译错误:
CS0246找不到类型或名称空间名称'AllowNullAttribute'(您是否缺少using指令或程序集引用?)ConsoleApp1(netstandard2.0)
文档Attributes extend type annotations包括这些类型
此代码有什么问题?