I can't set the file header template for C# in Rider

I'm using Rider 2025.2.4, non-commercial version, on Linux.

I just enabled StyleCop. Now, whenever StyleCop is enabled in File|Preferences|Editor|Code Style|Enable StyleCop support, this is the file header I get:

// <copyright file="Fake.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>

The text I enter in File|Preferences|Editor|File Header Template only works when StyleCop support is deactivated.

I added an .editorconfig file to the root of the project that contains:

[*.cs]
file_header_template = This is new.

It doesn't seem to have had any influence on Rider.

Is that normal? And, where can I set the header for files when using StyleCop?

Thanks!

1
3 comments

Hello,

It can be done using a stylecop.json file. Place it next to .csproj file and add the following content:

{
  "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
  "settings": {
    "documentationRules": {
      "companyName": "Your Company Name Inc.",
      "copyrightText": "Copyright (c) text. All rights reserved."
    }
  }
}

Then write this into .csproj:

    <ItemGroup>
    <AdditionalFiles Include="stylecop.json" />
    </ItemGroup>

This way you will get such a result:

Have a nice day!

0

Thank you so much! Sorry for the late reply, I didn't get any notification about it. I should have checked earlier.

0
Thank you for keeping me posted! I am glad to hear that I was able to help.
Should you have any other questions or difficulties in the future, do not hesitate to contact support.

Have a nice day!
0

Please sign in to leave a comment.