Deprecated after a certain date?

I would like to mark the method / class ... obsolete, but only after a certain date. For example, this class will be deprecated in 6 months to allow other developers to get time to implement the new architecture.

Is there an existing attribute in C #? Or should I implement my own?

All projects treat warnings as errors, so ObsoleteAttribute does not answer this question.

+3
source share
2 answers

Instead of baking this information in code, you usually publish a development roadmap with any disruptions that occur. Deprecated features do not necessarily disrupt changes.

IDE " ", VS, .

, , /, , .

" " , , . , , ( , ), , .

, - , .

+4

, - ?

void method()
{
    if(System.Diagnostics.Debugger.IsAttached) // you want your application to work, but warn developers
    {
        string DeprecatedFrom = "20001231"; //example date: 31 dec 2000
        if (string.Format("{0:yyyymmdd}",DateTime.Now).Equals(DeprecatedFrom)) throw new NotSupportedException("Don't use this method.");
    }
}

, : , 31 dec 2000 ( ).

+2

All Articles