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.
Asked
Active
Viewed 1,521 times
7
-
1possible duplicate of [How do I mark a method as Obsolete/Deprecated? - C#](http://stackoverflow.com/questions/1759352/how-do-i-mark-a-method-as-obsolete-deprecated-c) – Gishu Aug 08 '11 at 04:20
-
Are you asking if you can mark function from the .Net framework obsolete, or are you talking about related function you wrote? – Kratz Aug 08 '11 at 04:20
-
2No, only Microsoft can do that. You can derive a class from WebClient and apply the attribute. You then won't need an extension method anymore either, always better. – Hans Passant Aug 08 '11 at 04:23
-
@Hans why "always better", are extension methods have any issue or there are something else? – walter Aug 08 '11 at 04:27
2 Answers
7
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.

Michael Petrotta
- 59,888
- 27
- 145
- 179
2
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.

talo
- 41
- 2