The requested page is not available for the requested platform. You are viewing the content for Default platform.

Generic class cannot derive from Attribute

CodeRush Classic shows the Generic class cannot derive from Attribute code issue if a generic class derives from an attribute class.

Fix

Remove an attribute class from the current class ancestors or make the current class non-generic.

Purpose

Highlights the generic class declaration statements, which would cause the A generic type cannot derive from 'Class name' class because it is an attribute class compilation error.

Example

public class MyClass<T>: Attribute
{

}

Fixes:

public class MyClass<T>
{

}
public class MyClass: Attribute
{

}