Search code examples
c#visual-studioresharperstylecopvisual-studio-2019

How to set StyleCop company name and copyright? (VS2019 with R#)


ReSharper (with StyleCop plugin) helps to generate the header text of each file:

// -------------------------------------------------------
// <copyright file="Car.cs" company="">
//   
// </copyright>
// <summary>
//   Defines the Car type.
// </summary>
// -------------------------------------------------------

However, it keeps showing the following warning. Clicking on the suggestion does not fix it.

header text

How to configure this so it gets auto-filled or at least gets fixed by the ReSharper suggestion.

PS: None of the solutions present in this question are working with VS2019.


Solution

  • The solution was to manually add a new file to each project root called Settings.StyleCop. You can then add the copyright info and the company name accordingly. ReSharper will be able to place them correctly later on. You can use the same file for any further settings not available directly in the ReSharper options.

    <StyleCopSettings Version="105">
      <Analyzers>
        <Analyzer AnalyzerId="StyleCop.CSharp.DocumentationRules">
          <AnalyzerSettings>
            <StringProperty Name="CompanyName">PEAK Consulting Services GmbH</StringProperty>
            <StringProperty Name="Copyright">All Rights Reserved ©  2022</StringProperty>
          </AnalyzerSettings>
        </Analyzer>
      </Analyzers>
    </StyleCopSettings>