We are attempting to migrate a large code-base from one UI library to another. The 2 libraries are conceptually quite similar with some naming differences in most cases. We would like to automate as much of this as possible.
We want to implement something similar to Unity's API updater tool(https://docs.unity3d.com/Manual/APIUpdater.html) which automatically replaces calls to obsolete APIs. Are there are source weaving tools/frameworks for C#? I know there's Fody (https://github.com/Fody/Fody) but it operates at the IL level, not at the source level.
I would agree with @ta.speot.is from the comments, I guess Roslyn would be the best option here. The main advantages of Roslyn here are that it supports all (including the latest) features of C#, and that it does a semantic analysis, so you can actually know what method is meant and filter with that. The downside of Roslyn is that it is not really nice for code generation, because the data structures used by Roslyn are immutable, but unless your transformation is very complex, I guess this does not have to bother you much.
There is even an official example for using Roslyn for source code transformation, very close to what I believe you need: https://github.com/dotnet/roslyn/wiki/Getting-Started-C%23-Syntax-Transformation
Depending on the age of your code, CodeDOM could also be an alternative: Read the code as CodeDOM, transform the CodeDOM and generate code from it. However, CodeDOM was meant to support only the commonalities of all major .NET languages, so you will lose a lot if you do that. If your code uses things like lambda expressions or covariance, tuples or even coalesce operators (??
), I think CodeDOM is not going to help you much. Also, CodeDOM does not perform any semantic analysis. So, my recommendation would still be Roslyn.