Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p><strong>Short answer:</strong></p> </blockquote> <p>You will need to create a new nethod with the new signature, and mark the current as obsolete.</p> <blockquote> <p><strong>Longer answer</strong></p> </blockquote> <p>What you want to avoid at all cost is a code break! Then, particularly in a company framework, you want to advertise that your method will no longer be supported, for example, but you do not want to be responsible for depending solutions to crash because of an architecture or design decision or your side, right?</p> <p>The <a href="http://msdn.microsoft.com/en-us/library/system.obsoleteattribute.aspx" rel="noreferrer"><code>ObsoleteAttribute</code></a> class will do the trick for you.</p> <p>Once a class member marked as obsolete, a warning will be raised on the client-side, the ones who use your framework, to continue that way, or even one of your colleague under the same project.</p> <pre><code>public class MyClass { [Obsolete("This method should no longer be used, please use MyNewMethod() instead.")] public void MyMethod(string name, long phoneNumber, long faxNumber) { } public void MyNewMethod(string name, long phoneNumber, long faxNumber, string email) { } } </code></pre> <p>This will advertise that <code>MyMethod</code> is no longer supported throughout your code users.</p> <p>After a certain period of time, reasonable enough to allow everyone to change his/her code, you may tell this attribute to throw an error message when your obsolete method is still used in the code.</p> <pre><code>public class MyClass { [Obsolete("This method should no longer be used, please use MyNewMethod() instead.", true)] public void MyMethod(string name, long phoneNumber, long faxNumber) { } public void MyNewMethod(string name, long phoneNumber, long faxNumber, string email) { } } </code></pre> <p>By setting the second <code>ObsoleteAttribute</code> class constructor parameter to <code>true</code>, you tel the compiler to advertise the use of this method as an error.</p> <p>After some time only, you can completely remove your method from your code to clean it up a little. This is part of the refactoring methods encouraged by the Agile Software Development methodology.</p> <p>Does this help?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload