How to inject a new code in existing C# code (not MSIL) before compiling, but not change .cs file?
You can use the Text Template Transformation Toolkit (T4) to handle this type of scenario.
Use T4 templates which write to partial class files. This is the pattern used by Visual Studio--auto-generated code goes in partial files, while your code goes in the main .cs file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With