title: Getting custom attributes using reflection
body: <p>I am building a utility to run the unit test cases, where the user will be provided with the option to select the test they want to run. I am using reflection to get the methods. But it is not working</p>
  
  <pre><code>var assembly = Assembly.Load("TestingAssembly");
  var classes = assembly.GetTypes().Where(m =&gt; m.GetCustomAttributes(typeof(TestClassAttribute), false).Length &gt; 0);
   foreach (var type in classes)
   {
     var methods= type.GetTypes().Where(m1 =&gt; m1.GetCustomAttributes(typeof(TestMethodAttribute), false).Length &gt; 0);
   }
  </code></pre>
  
  <p>The classes object is always empty. If I iterate through the assembly.GetTypes and get the custom attributes it is returning the count. But still, I am not able to match it. In the below code the attributes contains an item with is TestClassAttribute. But when am matching the attribute's type to TestClassAttribute it fails.</p>
  
  <pre><code>foreach (Type type in assembly.GetTypes())
  {
    if (type.GetCustomAttributes().Count() &gt; 0)
     {
       var attributes = type.GetCustomAttributes();
         foreach (var item in attributes)
         {
           if (item.GetType() == Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute)
           {
              //Do something
           }
         }
     }
  }
  </code></pre>