gpt4 book ai didi

c# - .NET 6 源代码生成器和 C# 9 语法

转载 作者:行者123 更新时间:2023-12-05 04:31:11 27 4
gpt4 key购买 nike

如果源代码生成器项目必须以 netstandard2.0 ( C# 7.3 ) 为目标,.NET 6 incremental generator documentation 中的示例如何以及为什么这样做像静态匿名函数一样使用 C# 9 语法?

来自文档,按宽度格式化:

IncrementalValuesProvider<AdditionalText> textFiles =
context.AdditionalTextsProvider.Where(static file =>
file.Path.EndsWith(".txt"));

最佳答案

只需更改 .csproj 中的 C# 版本即可文件到 9,如 <LangVersion>9.0</LangVersion>

关于c# - .NET 6 源代码生成器和 C# 9 语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71878567/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com