It seems that the static method Attribute.IsDefined is missing for UWP apps, I can navigate to the metadata for the Attribute class alright and the method is there, but the project won't compile stating that 'Attribute' does not contain a definition for 'IsDefined' - weird (matter of fact, there are no static methods on that type at all according to IntelliSense).
I was going to query for types with a certain attribute like
var types = this.GetType().GetTypeInfo().Assembly.GetTypes()
.Where(t => Attribute.IsDefined(t, typeof (MyAttribute)));
and am wondering if there is a workaround.
This should work:
var types = this.GetType().GetTypeInfo().Assembly.GetTypes()
.Where(t => t.GetTypeInfo().GetCustomAttribute<MyAttribute>() != null);
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