Page MenuHomePhabricator

Csharp Stylecop
Updated 376 Days AgoPublic

  1. Apply D9717
  2. Apply D10433
  3. Configure meson with the -Ddotnet=true option
  4. Build it and see the warnings

You can customize the reports by editing the ruleset in src/bindings/mono/ca.ruleset.


Old Documentation

  1. Create a new project dir (e.g. code analysis) and enter it
  2. Create a new dotnet project: dotnet new classlib
  3. Add references to the analyzers nugets
dotnet add package Microsoft.CodeAnalysis.FxCopAnalyzers
dotnet add package StyleCop.Analyzers
dotnet restore
  1. Add a reference to the ruleset file in a property group
<PropertyGroup>
    <CodeAnalysisRuleSet>ca.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
  1. Copy the ruleset file from P278
  2. Copy the *.cs files from the EFL build and src/bindings/mono directories into a subdirectory (e.g. src) . Something like
mkdir -p src
find $EFL_ROOT/src/bindings/mono/ $EFL_BUILDROOT/src/bindings/mono/ -type f -name \*.cs | xargs cp -t src/
rm src/*Windows.cs
  1. Run dotnet build
  2. Behold the current warnings

The referenced ruleset ignores most layout, spacing, ordering and readability rules, as they don't impact the actual API much.

Source: https://carlos.mendible.com/2017/08/24/net-core-code-analysis-and-stylecop/

Last Author
lauromoura
Last Edited
Oct 16 2019, 8:26 PM
Projects
Subscribers
Jaehyun_Cho, felipealmeida, segfaultxavi, vitor.sousa