public void InjectionSanity() { ReadOnlyCollection <CodeInstruction> beforeInstructions = PatchTestHelper.GetInstructionsFromMethod(CyclopsSonarButton_Update_Patch.TARGET_METHOD); IEnumerable <CodeInstruction> result = CyclopsSonarButton_Update_Patch.Transpiler(CyclopsSonarButton_Update_Patch.TARGET_METHOD, beforeInstructions); Assert.IsTrue(beforeInstructions.Count < result.Count()); }
public void InjectionSanity() { ReadOnlyCollection <CodeInstruction> beforeInstructions = PatchTestHelper.GetInstructionsFromMethod(Equipment_RemoveItem_Patch.TARGET_METHOD); IEnumerable <CodeInstruction> result = Equipment_RemoveItem_Patch.Transpiler(Equipment_RemoveItem_Patch.TARGET_METHOD, beforeInstructions); Assert.IsTrue(beforeInstructions.Count < result.Count()); }
public void InjectionSanity() { IEnumerable <CodeInstruction> beforeInstructions = PatchTestHelper.GetInstructionsFromMethod(ConstructableBase_SetState_Patch.TARGET_METHOD); IEnumerable <CodeInstruction> result = ConstructableBase_SetState_Patch.Transpiler(ConstructableBase_SetState_Patch.TARGET_METHOD, beforeInstructions); Assert.IsTrue(beforeInstructions.Count() < result.Count()); }
public void InjectionSanity() { List <CodeInstruction> beforeInstructions = PatchTestHelper.GetInstructionsFromMethod(BaseGhost_Finish_Patch.TARGET_METHOD); IEnumerable <CodeInstruction> result = BaseGhost_Finish_Patch.Transpiler(BaseGhost_Finish_Patch.TARGET_METHOD, beforeInstructions); Assert.IsTrue(beforeInstructions.Count < result.Count()); }
public void InjectionSanity() { IEnumerable <CodeInstruction> beforeInstructions = PatchTestHelper.GetInstructionsFromMethod(CrashedShipExploder_Update_Patch.TARGET_METHOD); IEnumerable <CodeInstruction> result = CrashedShipExploder_Update_Patch.Transpiler(CrashedShipExploder_Update_Patch.TARGET_METHOD, beforeInstructions); Assert.IsTrue(beforeInstructions.Count() <= result.Count()); }
public void InjectionSanity() { ReadOnlyCollection <CodeInstruction> beforeInstructions = PatchTestHelper.GetInstructionsFromMethod(BuilderTool_HandleInput_Patch.TARGET_METHOD); IEnumerable <CodeInstruction> result = BuilderTool_HandleInput_Patch.Transpiler(BuilderTool_HandleInput_Patch.TARGET_METHOD, beforeInstructions); Assert.IsTrue(beforeInstructions.Count < result.Count()); }
public void InjectionSanity() { ReadOnlyCollection <CodeInstruction> beforeInstructions = PatchTestHelper.GetInstructionsFromMethod(ConstructorInput_OnCraftingBegin_Patch.TARGET_METHOD); IEnumerable <CodeInstruction> result = ConstructorInput_OnCraftingBegin_Patch.Transpiler(ConstructorInput_OnCraftingBegin_Patch.TARGET_METHOD, beforeInstructions); Assert.IsTrue(beforeInstructions.Count < result.Count()); }
public void InjectionSanity() { IEnumerable <CodeInstruction> beforeInstructions = PatchTestHelper.GetInstructionsFromMethod(IngameMenu_QuitGameAsync_Patch.targetMethod); IEnumerable <CodeInstruction> result = IngameMenu_QuitGameAsync_Patch.Transpiler(beforeInstructions); Assert.IsTrue(beforeInstructions.Count() == result.Count()); // The ifs in the target method are all false in the testing environment // so we are left with the same code instructions. }
public void InjectionSanity() { List <CodeInstruction> beforeInstructions = PatchTestHelper.GetInstructionsFromMethod(ClipMapManager_ShowEntities_Patch.TARGET_METHOD); IEnumerable <CodeInstruction> result = ClipMapManager_ShowEntities_Patch.Transpiler(ClipMapManager_ShowEntities_Patch.TARGET_METHOD, beforeInstructions); Assert.IsTrue(beforeInstructions.Count < result.Count()); }
public void InjectionSanity() { MethodInfo targetMethod = Reflect.Method(() => Builder.TryPlace()); ReadOnlyCollection <CodeInstruction> beforeInstructions = PatchTestHelper.GetInstructionsFromMethod(targetMethod); IEnumerable <CodeInstruction> result = Builder_TryPlace_Patch.Transpiler(targetMethod, beforeInstructions); Assert.IsTrue(beforeInstructions.Count < result.Count()); }
public void InjectionSanity() { DynamicMethod targetMethod = (DynamicMethod)AccessTools.Method(typeof(Builder), "TryPlace"); List <CodeInstruction> beforeInstructions = PatchTestHelper.GetInstructionsFromMethod(targetMethod); IEnumerable <CodeInstruction> result = Builder_TryPlace_Patch.Transpiler(targetMethod, beforeInstructions); Assert.IsTrue(beforeInstructions.Count < result.Count()); }
public void InjectionSanity() { MethodInfo targetMethod = AccessTools.Method(typeof(Constructable), "Construct"); List <CodeInstruction> beforeInstructions = PatchTestHelper.GetInstructionsFromMethod(targetMethod); IEnumerable <CodeInstruction> result = Constructable_Construct_Patch.Transpiler(targetMethod, beforeInstructions); Assert.IsTrue(beforeInstructions.Count < PatchTestHelper.GetInstructionCount(result)); }
public void InjectionSanity() { List <CodeInstruction> beforeInstructions = PatchTestHelper.GetInstructionsFromMethod(Pickupable_Drop_Patch.TARGET_METHOD); IEnumerable <CodeInstruction> result = Pickupable_Drop_Patch.Transpiler(Pickupable_Drop_Patch.TARGET_METHOD, beforeInstructions); Assert.IsTrue(beforeInstructions.Count < result.Count()); Assert.AreEqual(beforeInstructions.Count + 7, result.Count()); }
public void Sanity() { List <CodeInstruction> instructions = PatchTestHelper.GenerateDummyInstructions(100); instructions.Add(new CodeInstruction(Constructable_Construct_Patch.INJECTION_OPCODE, Constructable_Construct_Patch.INJECTION_OPERAND)); IEnumerable <CodeInstruction> result = Constructable_Construct_Patch.Transpiler(null, instructions); Assert.AreEqual(111, PatchTestHelper.GetInstructionCount(result)); }
public void Sanity() { List <CodeInstruction> instructions = PatchTestHelper.GenerateDummyInstructions(100); instructions.Add(new CodeInstruction(BaseGhost_Finish_Patch.INJECTION_OPCODE, BaseGhost_Finish_Patch.INJECTION_OPERAND)); IEnumerable <CodeInstruction> result = BaseGhost_Finish_Patch.Transpiler(null, instructions); Assert.AreEqual(instructions.Count + 3, result.Count()); }
public void Sanity() { List <CodeInstruction> instructions = PatchTestHelper.GenerateDummyInstructions(100); instructions.Add(new CodeInstruction(ConstructableBase_SetState_Patch.INJECTION_OPCODE, ConstructableBase_SetState_Patch.INJECTION_OPERAND)); IEnumerable <CodeInstruction> result = ConstructableBase_SetState_Patch.Transpiler(ConstructableBase_SetState_Patch.TARGET_METHOD, instructions); Assert.AreEqual(instructions.Count + 2, result.Count()); }
public void InjectionSanity() { List <CodeInstruction> beforeInstructions = PatchTestHelper.GetInstructionsFromMethod(ClipMapManager_HideEntities_Patch.TARGET_METHOD); IEnumerable <CodeInstruction> result = ClipMapManager_HideEntities_Patch.Transpiler(ClipMapManager_HideEntities_Patch.TARGET_METHOD, beforeInstructions); Assert.IsTrue(beforeInstructions.Count < result.Count()); // 3 instructions are added for every ret, currently there are two. Assert.AreEqual(beforeInstructions.Count + 6, result.Count()); }
public void Sanity() { List <CodeInstruction> instructions = PatchTestHelper.GenerateDummyInstructions(100); instructions.Add(new CodeInstruction(ClipMapManager_HideEntities_Patch.INJECTION_OPCODE, null)); IEnumerable <CodeInstruction> result = ClipMapManager_HideEntities_Patch.Transpiler(null, instructions); Assert.AreEqual(instructions.Count + 3, result.Count()); }
public void Sanity() { List <CodeInstruction> instructions = PatchTestHelper.GenerateDummyInstructions(100); instructions.Add(new CodeInstruction(OpCodes.Call, IngameMenu_QuitGameAsync_Patch.triggerOperand)); IEnumerable <CodeInstruction> result = IngameMenu_QuitGameAsync_Patch.Transpiler(instructions); Assert.AreEqual(instructions.Count, result.Count()); }
public void Sanity() { List <CodeInstruction> instructions = PatchTestHelper.GenerateDummyInstructions(100); instructions.Add(new CodeInstruction(BuilderTool_HandleInput_Patch.INJECTION_OPCODE, BuilderTool_HandleInput_Patch.INJECTION_OPERAND)); IEnumerable <CodeInstruction> result = BuilderTool_HandleInput_Patch.Transpiler(BuilderTool_HandleInput_Patch.TARGET_METHOD, instructions); Assert.AreEqual(instructions.Count + 5, result.Count()); }
public void Sanity() { List <CodeInstruction> instructions = PatchTestHelper.GenerateDummyInstructions(100); instructions.Add(new CodeInstruction(Equipment_RemoveItem_Patch.INJECTION_OPCODE)); IEnumerable <CodeInstruction> result = Equipment_RemoveItem_Patch.Transpiler(null, instructions); Assert.AreEqual(108, result.Count()); }
public void Sanity() { List <CodeInstruction> instructions = PatchTestHelper.GenerateDummyInstructions(100); instructions.Add(new CodeInstruction(ConstructorInput_OnCraftingBegin_Patch.INJECTION_OPCODE, ConstructorInput_OnCraftingBegin_Patch.INJECTION_OPERAND)); IEnumerable <CodeInstruction> result = ConstructorInput_OnCraftingBegin_Patch.Transpiler(null, instructions); Assert.AreEqual(instructions.Count + 3, result.Count()); }
public void Sanity() { List <CodeInstruction> instructions = PatchTestHelper.GenerateDummyInstructions(100); instructions.Add(new CodeInstruction(Constructable_Construct_Patch.AMOUNT_CHANGED_INJECTION_OPCODE, Constructable_Construct_Patch.AMOUNT_CHANGED_INJECTION_OPERAND)); instructions.Add(new CodeInstruction(Constructable_Construct_Patch.CONSTRUCTION_COMPLETE_INJECTION_OPCODE, Constructable_Construct_Patch.CONSTRUCTION_COMPLETE_INJECTION_OPERAND)); IEnumerable <CodeInstruction> result = Constructable_Construct_Patch.Transpiler(null, instructions); Assert.AreEqual(112, result.Count()); }
public void Sanity() { List <CodeInstruction> instructions = PatchTestHelper.GenerateDummyInstructions(100); instructions.Add(new CodeInstruction(CrashedShipExploder_Update_Patch.INJECTION_OPCODE, CrashedShipExploder_Update_Patch.INJECTION_OPERAND)); instructions.Add(new CodeInstruction(OpCodes.Brfalse)); IEnumerable <CodeInstruction> result = CrashedShipExploder_Update_Patch.Transpiler(null, instructions); Assert.AreEqual(instructions.Count + 2, result.Count()); }
public void Sanity() { List <CodeInstruction> instructions = PatchTestHelper.GenerateDummyInstructions(100); instructions.Add(new CodeInstruction(Builder_TryPlace_Patch.PLACE_BASE_INJECTION_OPCODE, Builder_TryPlace_Patch.PLACE_BASE_INJECTION_OPERAND)); instructions.Add(new CodeInstruction(Builder_TryPlace_Patch.PLACE_FURNITURE_INJECTION_OPCODE, Builder_TryPlace_Patch.PLACE_FURNITURE_INJECTION_OPERAND)); IEnumerable <CodeInstruction> result = Builder_TryPlace_Patch.Transpiler(null, instructions); Assert.AreEqual(121, result.Count()); }
public void Sanity() { List <CodeInstruction> instructions = PatchTestHelper.GenerateDummyInstructions(100); instructions.Add(new CodeInstruction(CyclopsSonarButton_Update_Patch.INJECTION_OPCODE, CyclopsSonarButton_Update_Patch.INJECTION_OPERAND)); instructions.Add(new CodeInstruction(OpCodes.Callvirt, Reflect.Method((Player player) => player.GetMode()))); instructions.Add(new CodeInstruction(OpCodes.Brtrue)); IEnumerable <CodeInstruction> result = CyclopsSonarButton_Update_Patch.Transpiler(null, instructions); Assert.AreEqual(instructions.Count + 2, result.Count()); }
public void CheckMethodValidity() { ReadOnlyCollection <CodeInstruction> instructions = PatchTestHelper.GetInstructionsFromMethod(CyclopsSonarButton_Update_Patch.TARGET_METHOD); for (int i = 0; i < instructions.Count; i++) { CodeInstruction instruction = instructions[i]; if (instruction.opcode.Equals(CyclopsSonarButton_Update_Patch.INJECTION_OPCODE) && instruction.operand.Equals(CyclopsSonarButton_Update_Patch.INJECTION_OPERAND)) { CodeInstruction nextBr = instructions[i + 2]; Assert.IsTrue(nextBr.opcode.Equals(OpCodes.Brtrue), "Looks like subnautica code has changed. Update jump offset!"); } } }