简体   繁体   English

.NET 6 StyleCop.Analyzers 忽略“documentationCulture”:“en-GB”

[英].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 :我使用 .NET 6 SDK (6.0.400),我有最简单的项目,涉及StyleCop.Analyzersstylecop.json

ClassLibrary1.csproj: 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: 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: 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:编译时,IDE(VS、Rider)和 CLI 报告以下警告:

warning SA1642: Constructor summary documentation should begin with standard text警告 SA1642:构造函数摘要文档应以标准文本开头

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.请注意,我在stylecop.json中有明确的“documentationCulture”:“en-GB” ,并且Class1构造函数在注释中有“ Initialis es ”字样,这对于“en-GB”文化是正确的。 But StyleCop wants me to change this word to default "Initiali z es" word of "en-US" culture, so ignoring documentationCulture parameter value.但是 StyleCop 希望我将这个词更改为“en-US”文化的默认“Initiali z es”词,因此忽略文档文化参数值。

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.我看到这个问题几年来在 GitHub 上的各种主题上一直存在,但我在任何地方都看不到真正有效的解决方案。

Straightforward solution简单的解决方案

It seems to be a known StyleCop.Analyzers issue:这似乎是一个已知的StyleCop.Analyzers问题:

Roughly speaking, the solution is:粗略地说,解决方案是:

  1. To communicate with the maintainers (for example, by posting comments on the GitHub issue).与维护者交流(例如,通过发表关于 GitHub 问题的评论)。
  2. If applicable, to wait for a next StyleCop.Analyzers release with the resolved issue.如果适用,等待具有已解决问题的下一个StyleCop.Analyzers版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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