Skip to content
mnaoumov.dev
Go back

WTF Generic attributes in C_

I have got another WTF just now.

I wrote a nice base class

 public abstract class ExceptionFilterBase<TException> : FilterAttribute, IExceptionFilter where TException : Exception { ... }

And when I tried to compile it I have got compilation error

CS0698: A generic type cannot derive from ‘FilterAttribute’ because it is an attribute class

What?! Why?! What’s wrong with it?

Later I found that it is some CLR limitation.

Very annoying :(

Another annoyances


Share this post on:

Previous Post
T4 blog section
Next Post
Sublime Text - The best text editor ever