简体   繁体   中英

.NET 6 StyleCop.Analyzers ignores "documentationCulture": "en-GB"

I use .NET 6 SDK (6.0.400) and I have the simplest possible project involving StyleCop.Analyzers and stylecop.json :

ClassLibrary1.csproj:

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

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

<ItemGroup>
  <PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
    <PrivateAssets>all</PrivateAssets>
    <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
  </PackageReference>
</ItemGroup>

Class1.cs:

// <copyright file="Class1.cs" company="My Company">
// Copyright (c) My Company. All rights reserved.
// </copyright>

namespace ClassLibrary1;

/// <summary>
/// Comment.
/// </summary>
public class Class1
{
    /// <summary>
    /// Initialises a new instance of the <see cref="Class1"/> class.
    /// Comment.
    /// </summary>
    public Class1()
    {
    }
}

stylecop.json:

 {
  "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
  "settings": {
    "documentationRules": {
      "companyName": "My Company",
      "documentationCulture": "en-GB"
    }
  }
}

When compiling, IDEs (VS, Rider) and CLI report the following warning:

warning SA1642: Constructor summary documentation should begin with standard text

Notice that I have explicit "documentationCulture": "en-GB" in stylecop.json , and Class1 constructor has " Initiali s es " word in comment, which is correct for "en-GB" culture. But StyleCop wants me to change this word to default "Initiali z es" word of "en-US" culture, so ignoring documentationCulture parameter value.

I see that this problem has been around since few years on various topics on GitHub, but I can't see the the real and effective solution anywhere.

Straightforward solution

It seems to be a known StyleCop.Analyzers issue:

Roughly speaking, the solution is:

  1. To communicate with the maintainers (for example, by posting comments on the GitHub issue).
  2. If applicable, to wait for a next StyleCop.Analyzers release with the resolved issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM