public static IEnumerable <CodeInstruction> SetPublicInstanceVariableTranspiler(IEnumerable <CodeInstruction> instr)
        {
            MethodInfo             info     = typeof(DummyModClass).GetMethod("SetPublicInstanceVariable");
            List <CodeInstruction> newInstr = ILTool.MethodToILInstructions(info);

            return(newInstr);
        }
        public void PrintIL()
        {
            MethodInfo thingMethod   = typeof(DummyModClass).GetMethod("SearchStatement");
            MethodInfo complexMethod = typeof(DummyCompiledClass).GetMethod("ComplexMethod");

            Trace.WriteLine("--SomeMethod--");
            ILTool.MethodToILInstructions(thingMethod).Do(x => Trace.WriteLine(x));
            Trace.WriteLine("");
            Trace.WriteLine("--ComplexMethod--");
            ILTool.MethodToILInstructions(complexMethod).Do(x => Trace.WriteLine(x));
        }
        /// <summary>
        /// Used strictly and only used in CompileIL test.
        /// This method compares the IL code of Harmony's transpiler and ILHelpers transpiler
        /// </summary>
        /// <param name="instr">Harmony's transpiled IL code</param>
        /// <returns>Instructions to replace patch statement</returns>
        public static IEnumerable <CodeInstruction> ILComparison(IEnumerable <CodeInstruction> instr)
        {
            // Complex method is used
            MethodInfo methodToCompare = typeof(DummyCompiledClass).GetMethod("ComplexMethod");

            List <CodeInstruction> helperInstructions  = ILTool.MethodToILInstructions(methodToCompare);
            List <CodeInstruction> harmonyInstructions = (List <CodeInstruction>)instr;

            // Verify helper and harmony instructions are equal
            Assert.AreEqual(harmonyInstructions.Count, helperInstructions.Count);

            for (int i = 0; i < helperInstructions.Count; i++)
            {
                // Check opcodes are equal
                Assert.AreEqual(harmonyInstructions[i].opcode, helperInstructions[i].opcode);
                // Check operands are equal
                Assert.AreEqual(harmonyInstructions[i].operand, helperInstructions[i].operand);

                // Check exception blocks are equal
                Assert.AreEqual(harmonyInstructions[i].blocks.Count, helperInstructions[i].blocks.Count);

                for (int j = 0; j < harmonyInstructions[i].blocks.Count; j++)
                {
                    Assert.AreEqual(harmonyInstructions[i].blocks[j], helperInstructions[i].blocks[j]);
                }

                // Check labels are equal
                Assert.AreEqual(harmonyInstructions[i].labels.Count, helperInstructions[i].labels.Count);

                for (int j = 0; j < harmonyInstructions[i].labels.Count; j++)
                {
                    Assert.AreEqual(harmonyInstructions[i].labels[j], helperInstructions[i].labels[j]);
                }
            }

            return(instr);
        }