Skip to content

Stylecop.Analyzers

Robert Logiewa edited this page Oct 2, 2015 · 1 revision

Preparing The Project

This project uses the new, Roslyn based, Stylecop.Analyzers for code analysis.

This means developers have to think differently then before. Stylecop.Analyzers can fix some of the errors themselves (such as a trailing whitespace), and do need much less attendance from the developer. As a big bonus it is also much faster than the old Stylecop.

There are some features that are not fully included in this version, or are bugged

  1. You cannot exclude files by specifying it in the *.csproj file, as an alternative you need to include // <auto-generated /> at the top of the file.
  2. When adding a new project, you manually need to add the stylecop.json file to the *.csproj file. After adding the file like always, you need to perform the following steps (taken from the official page
  1. Right click the project in Solution Explorer and select Unload Project. If you are asked to save changes, click Yes.
  2. Right click the unloaded project in Solution Explorer and select Edit ProjectName.csproj.
  3. Locate the following item in the project file.
    <None Include="stylecop.json" />
  4. Change the definition to the following.
    <AdditionalFiles Include="$(SolutionDir)stylecop.json" />
  5. Save and close the project file.
  6. Right click the unloaded project in Solution Explorer and select Reload Project. The stylecop.json file resides in the main GW2.NET folder bsides the .gitignore and the BasicRules.ruleset file, be sure to change the path accordingly.

Furthermore you need to add the *.ruleset file to each csproj file. To do this, add <CodeAnalysisRuleSet>$(SolutionDir)GW2NET.ruleset</CodeAnalysisRuleSet> inside each compile configuration PropertyGroup

Editing The Rules

If you think the rules should be changed, edit the GW2NET.ruleset file and send a pull request. The same goes for Stylecop.Analyzers settings.