Total .NET Analyzer Rule Documentation  

EmptyInterface Rule

Avoid using empty interface definitions.

Remarks

You should not define an interface without adding code. Interfaces should be used to denote contracts (or provide additional behavior for a class) not just to mark a class. An empty interface does not provide any additional behavior for a class. For example,


Public Interface IsEditable
' This is an empty interface, used simply to mark a class.
End Interface

Public Class MyFile
Implements IsEditable
' Some code here
End Class

Resolution

If you need to provide additional behavior for a class, you should add code to the interface. If you are simply using the interface to mark a class (or provide information rather than behavior), you should use an attribute instead. For instance, you could modify the example above to use an attribute:

Public Class IsEditable
Inherits Attribute
End Class

<IsEditable()> _
Public Class MyFile
' Some code here
End Class

See Also