/// <remarks>Implemented in IL because Debug builds insert arbitrary <c>if (true) {}</c> blocks.</remarks> public static string SwitchColor(int argument) { IL.DeclareLocals(new LocalVar(typeof(string))); Ldarg_0(); Switch("0_Red", "1_Orange", "2_Green"); Br_S("Default"); IL.MarkLabel("0_Red"); Ldstr("Red"); Stloc_0(); Br_S("End"); IL.MarkLabel("1_Orange"); Ldstr("Orange"); Stloc_0(); Br_S("End"); IL.MarkLabel("2_Green"); Ldstr("Green"); Stloc_0(); Br_S("End"); IL.MarkLabel("Default"); Newobj(MethodRef.Constructor(typeof(ArgumentOutOfRangeException))); Throw(); IL.MarkLabel("End"); Ldloc_0(); return(IL.Return <string>()); }
public StringBuilder CallNonDefaultConstructor() { Ldc_I4(42); Newobj(MethodRef.Constructor(typeof(StringBuilder), typeof(int))); return(IL.Return <StringBuilder>()); }
public void NotSameBasicBlock2() { Ldtoken(MethodRef.Constructor(typeof(BasicTestCases)) ?? MethodRef.Constructor(typeof(BasicTestCases))); }
public StringBuilder CallDefaultConstructor() { Newobj(MethodRef.Constructor(typeof(StringBuilder))); return(IL.Return <StringBuilder>()); }