StyleCop 4.7 是否与 C# 6.0 代码兼容 [英] Is StyleCop 4.7 compatible with C# 6.0 code
问题描述
我安装了 StyleCop 4.7 来开发自定义规则,以分析我们的 C# 代码.
我们在 Visual Studio 2015 中编写代码.我可以分析我的 C# 5.0 (Visual Studio 2013) 代码,并且我得到正确的响应,但是当我分析我的 C# 6.0 (Visual Studio 2015) 代码时,StyleCop 引发了一个异常我的规则.
现在我的问题是:
<块引用>StyleCop 4.7 是否与 C# 6.0 代码兼容?如果没有,我们有什么解决方案吗?
TL;DR - 是的.从 2016 年 3 月 13 日发布的 4.7.51(测试版)开始,StyleCop 4.7 已更新为与 C# 6 兼容.
早在 2016 年 1 月就有一个
这是一个活跃的项目,将为您提供有关 C# 6 功能的 StyleCop.有一个包 -
这会将它们添加到相关 *.ruleset
文件中的规则中(与 CodeAnalysis 规则位于同一位置,可从项目页面访问:)
给予:
你可以通过
运行它们具有与右键单击相同的效果,运行 StyleCop,用于以前的版本和 Visual StyleCop.
给予:
源代码在
在 R# 选项中给出了这个:
这为您提供语法突出显示,但没有右键单击运行,也没有构建集成.此外,R# 不是免费产品.
您可以使用插件对其进行扩展,但感觉不像其他两个选项那样可定制.
I installed StyleCop 4.7 for developing customized rules, to analyze our C# code.
We write the code in Visual Studio 2015. I can analyze my C# 5.0 (Visual Studio 2013) code, and I get correct response, but when I analyze my C# 6.0 (Visual Studio 2015) code, StyleCop raises an exception for my rules.
Now my question is:
Is StyleCop 4.7 compatible with C# 6.0 code? If not, do we have any solution?
TL;DR - Yes. StyleCop 4.7 was updated to be compatible with C# 6 starting with 4.7.51 (Beta) released on 13th March 2016.
There was a handover to new custodians back in January 2016, and a new version 4.7.50 alpha has been released 3rd Feb 2016, but as yet does not include C# 6 support.
4.7.51 (Beta) was released on 13th March 2016 and the latest stable is 4.7.54 released May 13th.
Here are three other options that work with Visual Studio 2015:
1. Visual StyleCop
Visual StyleCop, is an extension to Visual Studio. This gives you the right click functionality into Visual Studio 2015 that installing StyleCop gave you for 2013 and below.
This is available by adding an extension into Visual Studio:
It is an active project and will give you StyleCop on C# 6 features. There is a package - Visual-StyleCop.MSBuild, that will give you MSBuild integration.
It is possible to write custom rules with Visual StyleCop.
2. StyleCop Analyzers
StyleCop.Analyzers are built upon Rosalyn and make use of the Analyzers feature of Visual Studio 2015. They are available on NuGet:
This would add them into the rules in the relevant *.ruleset
file (same place as CodeAnalysis rules, accessible from the project page:)
giving:
and you can run them via
Which has the same effect as right click, Run StyleCop, used on previous versions and with Visual StyleCop.
Giving:
The source code is available on GitHub, so adding custom rules should be possible.
3. Resharper, with StyleCop by Jetbrains
Install:
- Resharper 10.0.1
- StyleCop by JetBrains 4.8
Which gives this in R# options:
This gives you syntax highlighting, but no right click run, and no build integration. Additionally, R# is not a free product.
You can extend it using plugins, but it doesn't feel as customizable as the other two options presented.
这篇关于StyleCop 4.7 是否与 C# 6.0 代码兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!