Stylecop配置文件在哪里

Stylecop配置文件在哪里

本文介绍了Stylecop配置文件在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过NuGet安装了Stylecop.我希望禁用一些规则,并且我知道可以通过阅读的配置文件来完成此操作.但是,我在任何地方都找不到该文件,并且似乎很少有文档描述在哪里创建该文件.

I've installed Stylecop via NuGet. I wish to disable some rules, and I know this can be done via a configuration file from what I've read. However, I can't find the file anywhere, and there seems to be little documentation describing where to create the file.

如何制作文件?

编辑:几年后,这个问题似乎仍然受到关注,因此我建议使用基于Roslyn Analyzer的StyleCop .

Edit: As this question still seems to be getting attention a couple of years later, I recommend using Roslyn Analyzer based StyleCop now.

这有一些优点:

  1. 它实际上已经维护并处于活动状态.
  2. 利用罗斯林(Roslyn)的优势,并可以为您进行一些更改.
  3. 这是一个NuGet软件包,因此已作为项目的一部分安装,这意味着您不再需要安装看似未经维护的StyleCop Visual Studio扩展(也就是说,您甚至可以找到合适的位置从一开始下载它!).这样,您可以在例如OSS中更轻松地实施代码样式/约定.
  4. 自动为您创建 .ruleset 文件,由于使用了Roslyn Analyzers,您将获得IDE支持以启用/禁用规则.
  1. It's actually maintained and active.
  2. Takes advantage of Roslyn, and can perform some changes for you.
  3. It's a NuGet package so is installed as part of your projects, meaning you no longer need to install the seemingly unmaintained StyleCop Visual Studio extension (that's if you can even find the right place to download it from in the first place!). This way you can enforce code style/conventions much easier in for example OSS.
  4. Automatically creates the .ruleset file for you, and as a result of using Roslyn Analyzers you get IDE support for enabling/disabling rules.

推荐答案

如果通过NuGet安装了Stylecop( StyleCop.MSBuild 包),那么您将没有其他答案中详细介绍的文件夹.

If you installed Stylecop via NuGet (the StyleCop.MSBuild package), then you will not have the folder detailed in the other answers.

您将在以下位置的项目文件夹中找到该文件:
包\ StyleCop.MSBuild.{version} \ tools \ Settings.StyleCop

You will find the file in your project folder here:
packages\StyleCop.MSBuild.{version}\tools\Settings.StyleCop

您应该将此文件复制到项目的根目录.

You should copy this file to the root of your project.

如果您不想手动编辑文件,则在tools文件夹中还有一个不错的GUI工具,称为StyleCopSettingsEditor,您可以将设置文件拖到其中.

If you would rather not manually edit the file, there is also a nice gui tool called StyleCopSettingsEditor in the tools folder, which you can just drag your settings file onto.

这篇关于Stylecop配置文件在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 08:30