visual studio - Best way to add overload methods to all methods in a C# file -
i quite new metaprogramming in c#, , looking pointers on how can achieve following. start these methods:
public jobject x(int a) public jobject y(int b) now, have requirement add optional parameter methods in file, while keeping backward compatibility. in order satisfy last requirement, need create new methods each of this:
public jobject x(int a) public jobject y(int b) public jobject x(int a, int o = defaultvalue) public jobject y(int b, int o = defaultvalue) now, problem have 50+ of these methods, , want avoid copy pasting things around if possible. don't have experience metaprogramming question is:
- any ways tooling around visual studio / resharper can me achieve that?
- should write script parses file , me? (any recommended resources there?)
- or should have fun copy pasting :( ?
thanks in advance!
script best option can think of off top of head.
though question brings out code smell me. optional arguments find irritating tend result in big complicated methods full of if elses. using optional arguments mean maintain backwards compatability adding them existing method call.
i think there's bigger design issue should looked @ around need add 50+ overloads optional arguments.
Comments
Post a Comment