One approach is to use the #pragma
directive.
In your class with the 'raw' method, add the following line at the top:
#pragma warning disable 0612
Mark your 'raw' method with the [Obsolete()] attribute.
So long as your class is the only class declared in the file with the pragma directive, any call to the raw method within that class will not raise a compiler warning. Calls made from other classes (files) will still raise a compiler warning similar to this:
c:\projects\ConsoleApplication1\ConsoleApplication1\Program.cs(13,13):
warning CS0612: 'ConsoleApplication1.Class1.Test()' is obsolete
e.g.
Program.cs
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Class1 c = new Class1();
c.Test(); // call the raw method but with a compiler warning
}
}
}
Class1.cs
#pragma warning disable 0612
using System;
namespace ConsoleApplication1
{
class Class1
{
[Obsolete()]
public void Test()
{
// the 'raw' method
}
private void CallTest()
{
Test(); // call the raw method without a compiler warning
}
}
}
When compiled, I get one compiler warning in Program.cs, not in Class1.cs
Health warning - this will suspend compiler warnings for calls made within Class1 to obsolete methods in other classes as well.