I've used the code from another answer to find classes in an assembly that are tagged with a specific custom attribute:
var allClasses = tpAssy.GetTypes();
var testClasses = from t in tpAssy.GetTypes()
let attributes = t.GetCustomAttributes(typeof(TestClassAttribute), true)
where attributes != null && attributes.Length > 0
select new { Type = t, Attributes = attributes.Cast<TestClassAttribute>() };
However, in my test-case assembly I can see that allClasses lists 4 classes, of which three are tagged with the custom attribute (TestClassAttribute) that I am interested in. but the second Linq query assigned to testClasses returns an empty enumeration.
Here's the code header for one such class:
[TestClass()]
public class BaseSessionTest
{...
This is VS2013 with .Net 4.5.
What gives?
Aucun commentaire:
Enregistrer un commentaire