[ObsoleteAttribute("Warning you want the compiler to give")] public void ObsoleteMethod() { // .... }If you now recompile your program, every call to ObsoleteMethod displays the message "Warning you want the compiler to give" in the output window - you might want to change that message to something more useful ;-).
Motto: "Talk is cheap, show me the code!"
This blog attempts to be a collection of how-to examples in the Microsoft software stack - things that may take forever to find out, especially for the beginner. I see it as my way to return something to the Microsoft community in exchange for what I learned from it.
04 March 2008
Simplyfying refactoring by making things obsolete
A very simple one I ran into today - when you are refactoring things, sometimes old methods are no longer required, but for the sake of backward compatiblity your want to retain them. To make sure your own code no longer calls the deprecated method, simply use the ObsoleteAttribute:
Geplaatst door
Joost van Schaik
op
Tuesday, March 04, 2008
Labels:
Architecture,
C#,
deprecated,
obsolete,
refactoring
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment