Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I create [experimental] tag in c# which throws a compiler warning [duplicate]

Tags:

c#

In c# I can mark some functions as obsolete by doing

[Obsolete]
void Foo()
{}

this tell the compiler to throw warning if I am using this function.

I want to create my own tag [Experimental] which just as obsolete throw a warning telling the user who build the code that this function is not well tested and using it may result in troubles.

Is it possible to do this? How?

like image 691
Petr Avatar asked Dec 01 '22 21:12

Petr


1 Answers

I want to create my own attribute [Experimental] which just as [Obsolete] does makes the compiler produce a warning. Is it possible to do this?

No, sorry. Obsolete is a very special attribute. The compiler has special-purpose code written for it. There is no extensible warning mechanism in C#.

If you would like to submit this suggestion to the Visual Studio team, you can do that at http://visualstudio.uservoice.com/.

like image 122
Eric Lippert Avatar answered Dec 09 '22 13:12

Eric Lippert