简体   繁体   English

ReSharper 和 StyleCop.Analyzers

[英]ReSharper and StyleCop.Analyzers

I installed the ReSharper plugin StyleCop by JetBrains to include StyleCop directly into all of our projects, without the need to have the same settings.stylecop or stylecop.json file in multiple projects (since our guidelines are basically identical for all of our projects).我安装了StyleCop by JetBrains将 StyleCop 直接包含到我们所有的项目中,而无需在多个项目中使用相同的settings.stylecopstylecop.json文件(因为我们所有项目的指南基本相同)。

I ran into an issue regarding StyleCop and after posting an issue on the Github page of the plugin I got told that I should use StyleCop.Analyzers since the plugin has been discontinued.我遇到了关于 StyleCop 的问题,在插件的 Github 页面上发布了一个问题后,我被告知我应该使用 StyleCop.Analyzers,因为该插件已停产。

Now I have the following problem.现在我有以下问题。 Do I need to explicitly include a corresponding stylecop.json file within each of our projects to make StyleCop work with the newest features?我是否需要在我们的每个项目中明确包含相应的stylecop.json文件以使 StyleCop 使用最新功能? Or is there another way to tell ReSharper to use a default StyleCop configuration for all of our projects?或者是否有另一种方法告诉 ReSharper 为我们所有的项目使用默认的 StyleCop 配置? I know it's not that big of a deal to add a file to a project.我知道将文件添加到项目中并不是什么大不了的事。 But it's a little bit tedious to have the same file within ~50ish projects and then change a single thing.但是在大约 50 个项目中拥有相同的文件然后更改一个东西有点乏味。 Therefore it would be amazing to configure it in one single location.因此,将其配置在一个位置将是惊人的。

The StyleCop.Analyzers NuGet package works with or without ReSharper. StyleCop.Analyzers NuGet package 可在有或没有 ReSharper 的情况下使用。 It will give you far better control over which projects it should apply to.它将让您更好地控制它应该应用于哪些项目。 You can configure it by right clicking the rules under Dependencies -> Analysers -> StyleCop.Analysers in your solution explorer:您可以通过右键单击解决方案资源管理器中的Dependencies -> Analysers -> StyleCop.Analysers下的规则来配置它:

在此处输入图像描述

Once you change any configuration it will create a .editorconfig file for you which you could use to copy to all of your other projects if required.一旦您更改任何配置,它将为您创建一个.editorconfig文件,如果需要,您可以使用该文件复制到所有其他项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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