Groups | Blog | Home
all groups > dotnet framework > april 2008 >

dotnet framework : How to write a .NET attribute which does just like ObsoleteAttribute...


Marc Gravell
4/24/2008 5:42:13 AM
You can't... ObsoleteAttribute is handled as a special-case by the
compiler, not by anything extensible.

What do you want to check, in particular? There may be other ways of
doing it...

Ignacio Machin ( .NET/ C# MVP )
4/24/2008 6:45:11 AM
[quoted text, click to view]

Hi,

AFAIK there is no way of doing that. The compiler knows a given number
of attributes and have CODED actions for them.
AshokG
4/24/2008 5:56:46 PM
Hi,

In .NET there is attribute named ObsoleteAttribute which is derived from
System.Attribute Class. This attribute when applied to a target (class or
method etc.) gives a compiler warning/error. I know we can write our own
attributes by inheriting the System.Attribute but I want to make it give
compiler warning or error when it is applied on the defined attribute
target.

How can we write such an attributes?

Regards,
Ashok G

AddThis Social Bookmark Button