All rules
IDE0077Miscellaneous rules

Avoid legacy format target in global SuppressMessageAttribute

Avoid legacy format target in global SuppressMessageAttribute

Microsoft docs

Description

This rule flags global SuppressMessageAttributes that specify Target using the legacy FxCop target string format. Using the legacy format Target is known to have performance problems and should be avoided. For more information, see dotnet/roslyn issue 44362.

The recommended format for Target is the *documentation ID* format. For information about documentation IDs, see Documentation ID format. Visual Studio 2019 provides a code fix to automatically change the Target of the attribute to the recommended format.

Example

// IDE0077: Legacy format target 'N.C.#F'
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Category", "Id: Title", Scope = "member", Target = "N.C.#F")]

// Fixed code
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Category", "Id: Title", Scope = "member", Target = "~F:N.C.F")]

namespace N
{
    class C
    {
        public int F;
    }
}
Group results
0 yes 0 no
ConsensusNone (disabled)
Severity preference (yes voters)
Suggestion0
Warning0
Error0