❔ Generalise Attributes?
Is there a way to generalise Attributes?
I'd like to create a library in which I can just pass in what Enum to watch out for.
So I'd like to replace the EPartnership/ECategory enum with any enum passed into the attribute.
What would be the smartest way to get around this?
6 Replies
seems to work fine?
Ah, right. Generics. I'm dumb lol
Thank you
Ah, I see. That's why I didn't know about it. Generic Attributes aren't a thing yet in .NET 6.0
Ah. I tested on 7.
Is upgrading an option?
In earlier versions, pass
object
or Enum
. It's not gonna be typesafe, but that's the best you can do
The other option would be making a generic one, and subclassing on that. The you can apply the concrete attribute typesYeah, that works for me. That just explained why I didn't know of it. 😄
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.