简体   繁体   中英

.NET 6 source generators and C# 9 syntax

If source generator projects must target netstandard2.0 ( C# 7.3 ), how and why do the examples in the .NET 6 incremental generator documentation use C# 9 syntax like static anonymous functions?

From the doc, formatted for width:

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

Just change the C# version in the .csproj file to 9, as in <LangVersion>9.0</LangVersion>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM