title: Do custom attribute classes inherit the "Inherited" AttributeUsage flag?
body: <p>Consider the following scenario:</p>
  
  <ul>
  <li>A base attribute class <code>BaseAttribute</code> has an <code>AttributeUsageAttribute</code> specifying that it is not inheritable (<code>Inherited = False</code>).</li>
  <li>A derived attribute class <code>DerivedAttribute</code> inherits from that base attribute class.</li>
  <li>A base domain class <code>Base</code> has the derived attribute applied.</li>
  <li>A domain class <code>Derived</code> inheriting from the base domain class is asked for its custom 
  attributes, including inherited attributes (<code>inherit: true</code>).</li>
  </ul>
  
  <p>Here is the corresponding code:</p>
  
  <pre><code>using System;
  using System.Linq;
  
  namespace ConsoleApplication26
  {
    class Program
    {
      static void Main ()
      {
        var attributes = typeof (Derived).GetCustomAttributes (true);
        foreach (var attribute in attributes)
        {
          Console.WriteLine (
              "{0}: Inherited = {1}",
              attribute.GetType().Name,
              attribute.GetType().GetCustomAttributes (typeof (AttributeUsageAttribute), true).Cast&lt;AttributeUsageAttribute&gt;().Single().Inherited);
        }
      }
    }
  
    [AttributeUsage (AttributeTargets.All, Inherited = false)]
    public class BaseAttribute : Attribute
    {
    }
  
    public class DerivedAttribute : BaseAttribute
    {
    }
  
    [Derived]
    public class Base
    {
    }
  
    public class Derived : Base
    {
    }
  }
  </code></pre>
  
  <p>In this scenario, the <code>GetCustomAttributes</code> API returns an instance of the <code>DerivedAttribute</code> class. I would have expected it to not return that instance because <a href="http://msdn.microsoft.com/en-us/library/system.attributeusageattribute.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.attributeusageattribute.aspx</a> says that the <code>AttributeUsageAttribute</code> is itself inheritable.</p>
  
  <p>Now, is this a bug, or is it to be expected/documented somewhere?</p>
  
  <p><strong>Note (2013-02-20):</strong> Experiments show that the <code>AttributeTargets</code> part of the <code>BaseAttribute</code> class is indeed inherited by the <code>DerivedAttribute</code> class. E.g., when I change the allowed targets on <code>BaseAttribute</code> to <code>AttributeTargets.Method</code>, the C# compiler won't allow me to apply <code>DerivedAttribute</code> to a class. Therefore, it doesn't make sense that the <code>Inherited = false</code> part is not inherited by <code>DerivedAttribute</code>, and I'm thus inclined to think of a bug in the implementation of <code>GetCustomAttributes</code>.</p>