问题详情
实现 IIncrementalGenerator 的类中,[Generator(LanguageNames.CSharp)] 出现编译警告
[Generator(LanguageNames.CSharp)]
public class PatternsGenerator : IIncrementalGenerator
{
//....
}
警告信息如下
This compiler extension should not be implemented in an assembly with target framework '.NET 10.0'. References to other target frameworks will cause the compiler to behave unpredictably.
csproj 中 PropertyGroup 部分的内容
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
</PropertyGroup>
回答
target framework 需要改为 netstandard2.0
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
版权:言论仅代表个人观点,不代表官方立场。转载请注明出处:https://www.stntk.com/question/2712.html
还没有评论呢,快来抢沙发~