public void ReassembleSimpleMethod() { var disassembler = new Disassembler(); var result = disassembler.Disassemble((Action)ReassembleSample); using (var assembleContext = new AssembleContext()) { var assembled = result.Assemble(assembleContext); assembled.Invoke(null, new object[] {}); // reassembled code is not in this class assembled.DeclaringType.IsNot(GetType()); } }
public void ReassembleAndTransformWithMethodMap() { var disassembler = new Disassembler(); var result = disassembler.Disassemble((Action)UsesDateTimeNow); using (var assembleContext = new AssembleContext()) { // maps DateTime.get_Now to DateTimeFake.get_Now result.MapMethod( typeof(DateTime).GetProperty("Now").GetMethod, typeof(DateTimeFake).GetProperty("Now").GetMethod); var assembled = result.Assemble(assembleContext); assembled.Invoke(null, new object[] {}); } }