gpt4 book ai didi

c# - Visual Studio 2015 - "Analyzers"引用是什么意思?

转载 作者:IT王子 更新时间:2023-10-29 03:41:24 26 4
gpt4 key购买 nike

在 Visual Studio 2015 预览版中创建一个普通的 C# 控制台应用程序,我们得到一个名为“Analyzers”的伪引用:


Expanded Solution Explorer project "References" showing "Analyzers" entry

上面提到的“分析器”是什么意思?

项目文件内部没有任何内容,属性窗口也没有显示任何关于此条目的内容(完全空白)(虽然,与“引用属性”相比,它在标题中显示“文件夹属性”,但这并没有说明太多)。

我希望这与 Roslyn 有关,但我不知道。我安装了 ReSharper,但我不认为这与它有任何关系。

编辑 6.8.2016

接受的答案解释了分析器提供的工具,但没有说明为什么开发工具成为(运行时?)引用。实际上它不是运行时引用,不像其他引用。所以这个奇迹的答案是 Hans Passants 在下面的评论:

They picked a clumsy place to add the code analyzers feature, they just couldn't find a better place without drastically overhauling the solution explorer and nuget. – Hans Passant May 26 '15 at 8:59

最佳答案

实时代码分析器 用于添加在您键入时实时显示的自定义错误消息和警告,以及自动代码修复以帮助您清理它们。它们以 NuGet 包的形式提供,您可以将它们添加到 Visual Studio 2015 中的项目中。

它是 Visual Studio 2015 最好和最有用的关键新功能之一,它允许 NuGet 包在您键入代码时在编辑器中实时启用自定义警告和错误,并使用自动代码修复为我们清理这些问题.

包甚至可以作为“代码感知库”捆绑在一起,同时引入 API 和特定领域的分析器,以确保您在使用它时保持正确。

从我们下载 NuGet 包的那一刻起,我们就会有针对性的指导。由于这些分析器是我们项目的一部分,您团队中的每个人都会看到相同的警告。

编辑 1:

分析器有如下附加的规则:

enter image description here

These rules focus on the most critical problems in your code, including potential security holes, application crashes, and other important logic and design errors. You should include this rule set in any custom rule set you create for your projects.

关于c# - Visual Studio 2015 - "Analyzers"引用是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27764967/

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