I am quite new to metaprogramming especially in C#, and so I am looking for good pointers on how I can achieve the following. We start with these methods:
public JObject x(int a)
public JObject y(int b)
Now, I have a requirement to add an optional parameter to all methods in this file, while keeping backward compatibility. So in order to satisfy the last requirement, I need to create new methods for each of those like 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, the problem is that I have 50+ of these methods, and I want to avoid copy pasting things around if possible. I don't have much experience with metaprogramming so my question is:
- Any ways the tooling around Visual Studio / ReSharper can help me achieve that?
- Should I write some script that parses my file and does this for me? (any recommended resources there?)
- Or should I just have fun copy pasting :( ?
Thanks in advance!