Let's say I have an enumeration of all currencies:
public enum CurrencyType
{
/// <summary>
/// United Arab Emirates dirham
/// </summary>
[EnumMember]
AED = 784,
/// <summary>
/// Afghan afghani
/// </summary>
[EnumMember]
AFN = 971,
/// <summary>
/// Albanian lek
/// </summary>
[EnumMember]
ALL = 008,
...
}
VS 2015 code analysis keeps complaining about 100 violations of CA1709 for every individual member.
This is an useful rule by itself, and I do not want to disable it; yet it is of not much help in this specific case, as CurrencyType
is public and is used in a whole lot of other projects.
I can suppress the message; however, VS only offers me to suppress it for every individual member - meaning that I'll have 100 [SuppressMessage(...)]
lines, which will clutter the code.
Is there any way to suppress all CA1709 for all CurrencyType
members, while not suppressing it for all other code in this project, without having to write 100 [SuppressMessage(...)]
?
There is a Scope
parameter of SuppressMessageAttribute
, but the documentation is unclear on that one. I've tried placing both
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", Scope = "type", Justification = "Currency codes are defined in ISO standard.")]
and
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", Scope = "member", Justification = "Currency codes are defined in ISO standard.")]
on CurrencyType
itself. Neither does work.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…