Custom Compiler Warnings
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.
This is worth a try.
You can't extend Obsolete, because it's final, but maybe you can create your own attribute, and mark that class as obsolete like this:
[Obsolete("Should be refactored")]
public class MustRefactor: System.Attribute{}
Then when you mark your methods with the "MustRefactor" attribute, the compile warnings will show. It generates a compile time warning, but the error message looks funny, you should see it for yourself and choose. This is very close to what you wanted to achieve.
UPDATE: With this code It generates a warning (not very nice, but I don't think there's something better).
public class User
{
private String userName;
[TooManyArgs] // Will show warning: Try removing some arguments
public User(String userName)
{
this.userName = userName;
}
public String UserName
{
get { return userName; }
}
[MustRefactor] // will show warning: Refactor is needed Here
public override string ToString()
{
return "User: " + userName;
}
}
[Obsolete("Refactor is needed Here")]
public class MustRefactor : System.Attribute
{
}
[Obsolete("Try removing some arguments")]
public class TooManyArgs : System.Attribute
{
}