summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-05-20 00:54:28 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-05-20 00:54:28 -0400
commit136a548fbbb27e28ac7b8167760388eb5754bdb9 (patch)
tree9efb8ea5da6a1358517241416384cda1cd415a03 /src
parent71a11337d6e51a1d95d3a40634f2ce319c330c33 (diff)
downloadSMAPI-136a548fbbb27e28ac7b8167760388eb5754bdb9.tar.gz
SMAPI-136a548fbbb27e28ac7b8167760388eb5754bdb9.tar.bz2
SMAPI-136a548fbbb27e28ac7b8167760388eb5754bdb9.zip
rewrite methods without a body (#711)
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs b/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs
index 5f7c2128..612d0fdd 100644
--- a/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs
+++ b/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs
@@ -67,7 +67,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Framework
anyRewritten |= this.RewriteCustomAttributes(type.CustomAttributes);
anyRewritten |= this.RewriteGenericParameters(type.GenericParameters);
- foreach (MethodDefinition method in type.Methods.Where(p => p.HasBody))
+ foreach (MethodDefinition method in type.Methods)
{
anyRewritten |= this.RewriteTypeReference(method.ReturnType, newType => method.ReturnType = newType);
anyRewritten |= this.RewriteGenericParameters(method.GenericParameters);
@@ -76,24 +76,27 @@ namespace StardewModdingAPI.Framework.ModLoading.Framework
foreach (ParameterDefinition parameter in method.Parameters)
anyRewritten |= this.RewriteTypeReference(parameter.ParameterType, newType => parameter.ParameterType = newType);
- foreach (VariableDefinition variable in method.Body.Variables)
- anyRewritten |= this.RewriteTypeReference(variable.VariableType, newType => variable.VariableType = newType);
-
- // check CIL instructions
- ILProcessor cil = method.Body.GetILProcessor();
- Collection<Instruction> instructions = cil.Body.Instructions;
- for (int i = 0; i < instructions.Count; i++)
+ if (method.HasBody)
{
- var instruction = instructions[i];
- if (instruction.OpCode.Code == Code.Nop)
- continue;
+ foreach (VariableDefinition variable in method.Body.Variables)
+ anyRewritten |= this.RewriteTypeReference(variable.VariableType, newType => variable.VariableType = newType);
- anyRewritten |= this.RewriteInstruction(instruction, cil, newInstruction =>
+ // check CIL instructions
+ ILProcessor cil = method.Body.GetILProcessor();
+ Collection<Instruction> instructions = cil.Body.Instructions;
+ for (int i = 0; i < instructions.Count; i++)
{
- anyRewritten = true;
- cil.Replace(instruction, newInstruction);
- instruction = newInstruction;
- });
+ var instruction = instructions[i];
+ if (instruction.OpCode.Code == Code.Nop)
+ continue;
+
+ anyRewritten |= this.RewriteInstruction(instruction, cil, newInstruction =>
+ {
+ anyRewritten = true;
+ cil.Replace(instruction, newInstruction);
+ instruction = newInstruction;
+ });
+ }
}
}
}