Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code analysis rule CA1040: Avoid empty interfaces, complains on a non empty interface

I have an interface that declares events

interface IMyInterface
{
event SomeHandler MyEvent1;
event SomeHandler MyEvent2;
...
}

but when I enable the Code analysis rule CA1040: Avoid empty interfaces, it complains that my interface violates this rule, any ideas how to solve it?

like image 779
Pablo Retyk Avatar asked Nov 03 '22 02:11

Pablo Retyk


1 Answers

The reason why it complains, is because this interface does not requires any implamentation. You cannot implement an event declaration in any specific way.

As Matthew suggest, just suppress it. you might need to add this in the top of you class:

#define CODE_ANALYSIS

or the suppresion is ignored.

Edit

It might be a bug after all, as any classes that inherit the interface is infact requeried to "implement" it - hence : it is not an empty interface.

like image 122
Jens Kloster Avatar answered Nov 13 '22 07:11

Jens Kloster