From ff1492aa614f7141a1d0b67b6da319f6f69aa87d Mon Sep 17 00:00:00 2001 From: Maik Macho Date: Mon, 3 Feb 2020 22:19:55 +0100 Subject: [PATCH] Fix variable definition order: keep orig vars first --- Harmony/Internal/MethodPatcher.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Harmony/Internal/MethodPatcher.cs b/Harmony/Internal/MethodPatcher.cs index c66b1f1d..42113457 100644 --- a/Harmony/Internal/MethodPatcher.cs +++ b/Harmony/Internal/MethodPatcher.cs @@ -70,6 +70,7 @@ internal MethodInfo CreateReplacement() { try { + var originalVariables = DeclareLocalVariables(source ?? original); var privateVars = new Dictionary(); LocalBuilder resultVariable = null; @@ -110,7 +111,6 @@ internal MethodInfo CreateReplacement() var skipOriginalLabel = il.DefineLabel(); var canHaveJump = AddPrefixes(privateVars, skipOriginalLabel); - var originalVariables = DeclareLocalVariables(source ?? original); var copier = new MethodCopier(source ?? original, il, originalVariables); foreach (var transpiler in transpilers) copier.AddTranspiler(transpiler);