As the question states; is it possible to suppress all specified warmings that appears within a class? I’ve been trying out attributes along the lines of:
namespace Testing2k.Collections
{
/// <summary>
/// Represents a collection that utilizes an array internally to store it's content.
/// </summary>
/// <typeparam name="T"> The type of elements contained in the collection. </typeparam>
[SuppressMessage("Microsoft.Performance", "CA1800", Justification = "Choosing readability over a trivial optimalization.", Target = "Testing2k.Collections.ArrayBasedCollection<T>")]
public abstract class ArrayBasedCollection<T> : ArrayBasedStructure<T>, ICollection<T>, IEnumerable<T>
{
// ...
}
}
None of them seem to do anything, so I’m wondering what the correct way to do it is, if it’s even possible.
You seem to have it mostly right.
SuppressMessageAttribute has a
[Conditional("CODE_ANALYSIS")]attribute applied to it, so make sure you have defined theCODE_ANALYSISconditional compilation symbol.In addition, you can try changing that
"CA1800"to"CA1800:DoNotCastUnnecessarily".