Reputation: 10932
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.
Upvotes: 5
Views: 847
Reputation: 566
This should work:
var types = this.GetType().GetTypeInfo().Assembly.GetTypes()
.Where(t => t.GetTypeInfo().GetCustomAttribute<MyAttribute>() != null);
Upvotes: 3