Search code examples
buildwarningsstylecop

StyleCop warning not suppressed


I want to suppress stylecop warnings for a method. So I added the following 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)
    {
       ...
    }
    ...
}

But this is still giving a warning on a console build: D:\ProjectSolutionDir\ProjectSolution\Helpers\OffersDataProcessor.cs(26, 1): warning : SA1306 : CSharp.Naming : Variable names and private field names must start with a lower-case letter: BaseUrl. [D:\ProjectSolutionDir\ProjectSolution.csproj]

The line 26, 1 is where BaseUrl is present. Should I add something else to suppress the warnings?


Solution

  • The issue was an incorrect namespace. I had to use Microsoft.StyleCop.CSharp.NamingRules and not Microsoft.StyleCop.CSharp.Naming. That fixed the problem.