Hi folks. As part of the xunitcontrib project on CodePlex, I'm writing the unit test runner for xUnit.net. I've run across something a little odd in my implementation of IUnitTestProvider.ExploreAssembly. Given an IMetadataAssembly, I'm getting all public types, and for each type, I get it's custom attributes by calling IMetadataTypeInfo.CustomAttributes. This returns me back an array of IMetadataCustomAttribute. Phew.
Now, to get the type of the attribute, you need to navigate through the UsedConstructor property and get it's DeclaringType property.
This works fine for a custom attribute that has a constructor argument of (for example) a string.
I've got a problem with a constructor argument of System.Type, such as RunWith(typeof(ThingCommand)).
If the attribute is defined in the same assembly as the class it's applied to, then the UsedConstructor property is populated, and I can get the DeclaringType and all is good.
However, if the attribute is defined in a separate assembly, then UsedConstructor is always null, and I now don't know how to get the type of the attribute, or the value passed to the constructor.
Again, a custom attribute with a string constructor will work fine, if the attribute is defined in the same assembly or a referenced assembly.
Is this a ReSharper bug? I've tried it in 4.5 and 4.1 with the same results.