1

Is it possible to change code in a non-virtual method using Fody or some other framework? I'm not looking to mock it but rather change the code in the generated assembly at compile-time.

Ex. I would like to change:

private int SomeInt() { return 1; }

to

private int SomeInt() { return 42; }

in an assembly without mocking it.

  • Yes, it's possible to do that with Fody. But writing a Fody plugin is non trivial. – Kirk Woll Jun 18 '16 at 12:21
  • @KirkWoll Is Fody ModuleWeaver the simplest path? Got a link that I can look at? TIA I've only used Fody ModuleInitializer before. –  Jun 18 '16 at 12:22
  • Creating a module weaver is the only way to write a fody plugin. After looking at the [sample](https://github.com/Fody/BasicFodyAddin), your best bet is to look at the [suite of existing](https://github.com/Fody/FodyAddinSamples) plugins. – Kirk Woll Jun 18 '16 at 12:25

0 Answers0