<p>When using the ObsoleteAtribute in .Net it gives you compiler warnings telling you that the object/method/property is obsolete and somthing else should be used. I'm currently working on a project that requires a lot of refactoring an ex-employees code. I want to write a custom attribute that I can use to mark methods or properties that will generate compiler warnings that give messages that I write. Something like this</p>

<pre class="lang-cs prettyprint-override"><code>[MyAttribute("This code sux and should be looked at")]
public void DoEverything()
{
}
</code></pre>

<pre class="lang-vb prettyprint-override"><code>&lt;MyAttribute("This code sux and should be looked at")&gt;
Public Sub DoEverything()
End Sub
</code></pre>

<p>I want this to generate a compiler warning that says, "This code sux and should be looked at". I know how to create a custom attribute, the question is how do I cause it to generate compiler warnings in visual studio.</p>

In some compilers you can use #warning to issue a warning:
```
```
#warning "Do not use ABC, which is deprecated. Use XYZ instead."
```
```
In Microsoft compilers, you can typically use the message pragma:
```
```
#pragma message ( "text" )
```
```
You mentioned .Net, but didn't specify whether you were programming with C/C++ or C#. If you're programming in C#, than you should know that
C# supports the #warning format
.