Visual Studio 2015-什么是“分析器"?参考是什么意思? [英] Visual Studio 2015 - What does the "Analyzers" reference mean?

查看:102
本文介绍了Visual Studio 2015-什么是“分析器"?参考是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Creating a plain C# Console App in Visual Studio 2015 Preview, we get a pseudo reference named "Analyzers":


上面的分析器"参考是什么意思?

项目文件内部没有内容,并且属性窗口中没有任何关于此条目的信息(完全空白)(尽管与引用属性"相反,它在标头中显示文件夹属性",但并没有太多说明).

The project file has nothing inside and the properties window shows nothing (completely blank) about this entry (though, in contrast to "reference properties" it says "folder properties" in the header, but that does not say much).

我希望这与罗斯林有关,但我不知道.我已经安装了ReSharper,但我不认为它与此有关.

I would expect this to be related to Roslyn, but I have no idea. I have ReSharper installed, but I don't assume it has anything to do with it.

编辑6.8.2016

可接受的答案说明了分析器提供的工具,但未说明为什么开发工具成为(运行时?)参考.实际上,它与其他引用不同,它不是运行时引用.因此,这个奇迹的答案是Hans Passants在下面的评论:

The accepted answer explains the tooling provided by analyzers, but leaves open why a development tool becomes a (runtime?) reference. Actually it is not a runtime reference, unlike the other references. So the answer to this miracle is Hans Passants comment below:

他们选择了一个笨拙的地方来添加代码分析器功能,如果不彻底修改解决方案资源管理器和nuget,他们只是找不到更好的地方.–汉斯·帕桑(Hans Passant),2015年5月26日上午8:59

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中的项目中.

Live Code Analyzers are used to add custom error messages and warnings that appear live as you're typing, along with automatic code fixes to help you clean them up. They are available as NuGet packages that you add to your projects in Visual Studio 2015.

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

It is one of the best and helpful key new features of Visual Studio 2015 that lets a NuGet package enable custom warnings and errors in the editor live as you type the code, with automatic code fixes that can clean up those issues for us.

甚至可以将软件包捆绑在一起,成为一个代码感知库",其中引入了API和特定于域的分析器,以确保您在使用时始终如一.

Packages can even be bundled together as a "code-aware library" that pulls in both an API and the domain-specific analyzers to make sure that you stay on course when using it.

从下载NuGet软件包开始,我们将提供有针对性的指导.而且由于这些分析仪是我们项目的一部分,因此您团队中的每个人都可以看到相同的警告.

We'll have a targeted guidance from the moment we download the NuGet package. And because these analyzers are part of our project, everyone on your team gets to see the same warnings.

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

这些规则着重于代码中最关键的问题,包括潜在的安全漏洞,应用程序崩溃以及其他重要的逻辑和设计错误.您应将此规则集包含在您为项目创建的任何自定义规则集.

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.

这篇关于Visual Studio 2015-什么是“分析器"?参考是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆