I'm having the following problem when using reflection.
The following statement evaluates to false:
object[] attributes = someType.GetCustomAttributes(true);
if (attributes[0] is NUnit.Framework.TestFixtureAttribute)
return true;
However this evaluates to true:
object[] attributes = someType.GetCustomAttributes(true);
if (attributes[0].ToString() == "NUnit.Framework.TestFixtureAttribute")
return true;
Any ideas why?
Perhaps it's loading a different version of the assembly?
Compare attributes[0].GetType().Assembly
with typeof(NUnit.Framework.TestFixtureAttribute).Assembly
.
Just perform a reference type comparison - even if two Assembly
instances have been loaded from the exact same file, if they're two separate instances, any types created from them will be distinct (making is
fail).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With