title: C# What does using the [System.Diagnostics.Conditional] attribute on an attribute class actually do
body: <p>I've known about using the conditional attribute on methods for a while now, but I just found out that it can also be used on attribute classes, so I wrote some code to test it, but its not performing as expected.</p>
  
  <p>This MSDN page shows how to use the conditional attribute on an attribute class down the bottom of the page: <a href="https://msdn.microsoft.com/en-us/library/4xssyw96%28v=vs.90%29.aspx" rel="nofollow">https://msdn.microsoft.com/en-us/library/4xssyw96%28v=vs.90%29.aspx</a>.</p>
  
  <p>I'm using the Unity engine by the way. I don't think that should matter, but it might I guess.</p>
  
  <p>Here's the test code I wrote:</p>
  
  <pre><code>using System.Reflection;
  using UnityEngine;
  
  [System.Diagnostics.Conditional("UNITY_EDITOR")]
  public class TestAttribute : System.Attribute
  {
      public string text;
  
      public TestAttribute(string text)
      {
          this.text = text;
      }
  }
  
  public class NewBehaviourScript : MonoBehaviour
  {
      [Test("This shouldn't exist on android")]
      public void Awake()
      {
  #if UNITY_EDITOR
          Debug.Log("This only gets logged in the Unity Editor, not in an Android build");
  #endif
  
          Debug.Log("Begin Attribute Test");
          {
              object[] attributes = typeof(NewBehaviourScript).GetMethod("Awake").GetCustomAttributes(true);
              for (int i = 0; i &lt; attributes.Length; i++)
              {
                  Debug.Log(attributes[i]);// This logs TestAttribute both in the editor and on android.
              }
  
              TestAttribute att = attributes[0] as TestAttribute;
              Debug.Log(att.text);// This logs "This shouldn't exist on android" both in the editor and on android.
          }
          Debug.Log("End Attribute Test");
          Debug.Log("");
          Debug.Log("Begin Method Test");
          {
              Method();// This only gets called in the Unity Editor, as expected from the conditional attribute.
  
              MethodInfo methodInfo = typeof(NewBehaviourScript).GetMethod("Method");
              Debug.Log(methodInfo);// this logs "void Method()" both in the editor and on android.
          }
          Debug.Log("End Method Test");
      }
  
      [System.Diagnostics.Conditional("UNITY_EDITOR")]
      public void Method()
      {
          Debug.Log("This shouldn't exist on android either");
      }
  }
  </code></pre>
  
  <p>If the conditional attribute doesn't stop GetCustomAttributes() from getting the test attribute, what does it actually do?</p>