点击上方蓝字
关注我们
(本文阅读所需15分钟)
今天 , 我们很高兴发布 .NET 7 预览版 2 。 .NET 7 的第二个预览版包括对 RegEx 源生成器的增强、将 NativeAOT 从实验状态转移到运行时的进展 , 以及对“dotnet new”CLI 的一系列重大改进经验 。 这些可供您立即获取并开始尝试新功能 , 例如:
- 在编译时使用源生成器而不是在运行时使用较慢的方法来构建专门的 RegEx 模式匹配引擎 。
- dotnet new 利用 SDK 改进提供全新的简化选项卡完成体验来探索模板和参数 。
- 用你自己的创新解决方案尝试 NativeAOT 。
▌ 引入新的正则表达式源生成器
新正则表达式源生成器带来了我们编译引擎的更多性能优势 , 而无需额外成本 , 它还可以提供出色的调试体验以及便于修剪 。 如果您的模式在编译时是已知的 , 那么新的正则表达式源生成器可以很好地帮到您 。
您只需要将包含类型转换为部分类型 , 并使用 RegexGenerator 属性声明一个新的部分方法 , 该方法将返回优化的 Regex 对象 。 源代码生成器将为您填充该方法的实现 , 并在您更改模式或传入的其他选项时自动更新 。
更新前
更新后
▌SDK 改进
- [Epic] 新的 CLI 解析器 + 选项卡完成 #2191
以下是新的帮助输出示例:
Arguments:< template- short-name> A shortname of the templateto create. < template-args> Template specific options to use.
Options:-?, -h, --help Show command line help.
Commands:install <package> Installs a templatepackage. uninstall <package> Uninstalls a templatepackage. update Checks the currently installed templatepackages forupdate, andinstall the updates. search < template-name> Searches forthe templates on NuGet.org. list< template-name> Lists templates containing the specified templatename. If no name is specified, lists all templates.
- 新命令名称
- Tab自动补全
特别声明:本站内容均来自网友提供或互联网,仅供参考,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
