【问题标题】:StyleCop warning not suppressedStyleCop 警告未抑制
【发布时间】:2015-04-20 00:33:18
【问题描述】:

我想禁止一个方法的 stylecop 警告。所以我添加了以下 SuppressMessage:

[SuppressMessage("Microsoft.StyleCop.CSharp.Naming", "SA1306:FieldNamesMustBeginWithLowerCaseLetter", Justification = "MDS tables names need to be in capital letters")]
internal static class OffersDataProcessor
{
    public static async Task<List<Offer>> RetrieveAndProcessOffersAsync(string BaseUrl, string baseUrlKey)
    {
       ...
    }
    ...
}

但这仍然在控制台构建上发出警告: D:\ProjectSolutionDir\ProjectSolution\Helpers\OffersDataProcessor.cs(26, 1):警告:SA1306:CSharp.Naming:变量名称和私有字段名称必须以小写字母开头:BaseUrl。 [D:\ProjectSolutionDir\ProjectSolution.csproj]

第 26, 1 行是 BaseUrl 所在的位置。我应该添加其他东西来抑制警告吗?

【问题讨论】:

    标签: build warnings stylecop


    【解决方案1】:

    问题是命名空间不正确。我必须使用 Microsoft.StyleCop.CSharp.NamingRules 而不是 Microsoft.StyleCop.CSharp.Naming。这解决了问题。

    【讨论】: