2012-01-22 29 views
0

正如问题所述;是否可以抑制出现在课堂上的所有指定的热身?我一直在尝试了线沿线的属性:SuppressMessageAttribute;抑制一个班级内的所有警告

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> 
    { 
     // ... 
    } 
} 

他们似乎都不做任何事情,所以我不知道该怎么做了正确的事情是这样的,如果它甚至有可能。

回答

0

你似乎大部分都是正确的。

SuppressMessageAttribute有一个[Conditional("CODE_ANALYSIS")]属性应用于它,所以请确保您已经定义了CODE_ANALYSIS条件编译符号。

另外,您可以尝试将"CA1800"更改为"CA1800:DoNotCastUnnecessarily"