Unable to check for existence of unbound generic typed attribute on type
I'm looking to build out the behavior of a Blazor component based on the attributes applied to the type:
In one of the logging examples, we do something similar with:
This works fine, but in my larger example above, it never shows the introduced method even though it appears to be the same thing.
Am I doing something wrong or does the
OfAttributeType
method not handle unbound generic types in a typeof
well unlike non-generic attributes?
Thanks!5 Replies
Testing further, if I add an attribute without a generic type:
and decorate my target class accordingly:
And then update the aspect to include a check for this attrbute:
And then finally update the logic to add the method or not:
Then it works, indicating that it's an identification issue with the unbound generically typed attribute as if there's no generic type involved, it works as expected.
I have filed an enhancement request.
In the meantime, you should use something like this:
That doesn't seem to be working either - when using:
The method is never introduced in the preview even though the attribute is attached:
Sorry, I forgot the
TypeDefinition
part:
That did the trick. Thank you!