I have created a few WebRequest extension methods that support cancelling. Is it possible to mark related .net framework methods as Obsolete. That will allow other developers to get warning and encourage them to use a new extension methods.
In you examples the "Method1 is deprecated" part is rather redundant. By marking it as obsolete you are saying that it is indeed obsolete, so no need to restate it in the message. Especially since the resulting warning/error will read 'Method1' is obsolete: 'Method1 is deprecated, please use Method2 instead.
An obsolete attribute, in C#, is a declarative tag used while declaring a type or a member of a type to indicate that it should no longer be used.
The . NET Framework indicates that a type or type member is obsolete by marking it with the ObsoleteAttribute attribute. Applying the attribute to a type or member indicates that type or member will be removed in some future version of the . NET Framework without breaking compiled code that uses that member.
NET Framework will be deprecated. This means you can only use . NET Framework as long as your operating systems (for example Windows Server 2019) still supports it. And with Microsoft shortening its support lifecycles, your operating system end-of-life will come sooner than you may think.
If you're asking if you can mark methods from the Base Class Libraries with the Obsolete
(or any) attribute, the answer is no. You must control the source for methods you want to mark up with attributes.
You can probably redefine the .Net Framework WebRequest class in the same assembly where the extension methods are defined under System.Net namespace.
The new redefined WebRequest class can then extend the original System.Net.WebRequest class and override the existing relevant method with [Obsolete] tag.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With