【发布时间】:2022-06-11 04:06:20
【问题描述】:
如果源代码生成器项目必须以netstandard2.0 (C# 7.3) 为目标,那么.NET 6 incremental generator documentation 中的示例如何以及为什么像静态匿名函数一样使用C# 9 语法?
来自文档,按宽度格式化:
IncrementalValuesProvider<AdditionalText> textFiles =
context.AdditionalTextsProvider.Where(static file =>
file.Path.EndsWith(".txt"));
【问题讨论】:
-
如果您以
netstandard2.0为目标,您可以实际上使用比7.3 更高的C# 语言版本,这是构建系统中的人为限制(grrrrr)。它很复杂,到目前为止我只让它在多目标项目中工作,例如meziantou.net/…(哦,由于某种原因,我所有的多目标项目都确实减慢了 VS 2019 的速度......) -
@Dai This blog post 也掩盖了它。也许我是唯一一个没有破解我的语言版本的人!
标签: c# .net-6.0 csharp-source-generator