[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


About mnaoumov

Senior .NET Developer in Readify
This entry was posted in Uncategorized and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s