From 6edcfb1358e470a636a9e97780e05f2a0dcb6752 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 29 Aug 2021 23:01:47 -0400 Subject: tweak new code --- src/SMAPI/Framework/ModLoading/AssemblyLoader.cs | 4 ++-- .../Framework/ModLoading/Framework/RecursiveRewriter.cs | 5 +++-- .../ModLoading/Rewriters/ArchitectureAssemblyRewriter.cs | 13 +++++-------- 3 files changed, 10 insertions(+), 12 deletions(-) (limited to 'src/SMAPI/Framework/ModLoading') diff --git a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs index ae42909c..7668e8a9 100644 --- a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs +++ b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs @@ -336,11 +336,11 @@ namespace StardewModdingAPI.Framework.ModLoading IInstructionHandler[] handlers = new InstructionMetadata().GetHandlers(this.ParanoidMode, platformChanged, this.RewriteMods).ToArray(); RecursiveRewriter rewriter = new RecursiveRewriter( module: module, - rewriteModule: (module) => + rewriteModule: curModule => { bool rewritten = false; foreach (IInstructionHandler handler in handlers) - rewritten |= handler.Handle(module); + rewritten |= handler.Handle(curModule); return rewritten; }, rewriteType: (type, replaceWith) => diff --git a/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs b/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs index 52f4003c..4f14a579 100644 --- a/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs +++ b/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs @@ -37,7 +37,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Framework /// The module to rewrite. public ModuleDefinition Module { get; } - /// Handle or rewrite a type reference if needed. + /// Handle or rewrite a module definition if needed. public RewriteModuleDelegate RewriteModuleImpl { get; } /// Handle or rewrite a type reference if needed. @@ -52,6 +52,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Framework *********/ /// Construct an instance. /// The module to rewrite. + /// Handle or rewrite a module if needed. /// Handle or rewrite a type reference if needed. /// Handle or rewrite a CIL instruction if needed. public RecursiveRewriter(ModuleDefinition module, RewriteModuleDelegate rewriteModule, RewriteTypeDelegate rewriteType, RewriteInstructionDelegate rewriteInstruction) @@ -72,7 +73,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Framework try { - changed |= this.RewriteModuleImpl( this.Module ); + changed |= this.RewriteModuleImpl(this.Module); foreach (var type in types) changed |= this.RewriteTypeDefinition(type); diff --git a/src/SMAPI/Framework/ModLoading/Rewriters/ArchitectureAssemblyRewriter.cs b/src/SMAPI/Framework/ModLoading/Rewriters/ArchitectureAssemblyRewriter.cs index 216c042a..cc830216 100644 --- a/src/SMAPI/Framework/ModLoading/Rewriters/ArchitectureAssemblyRewriter.cs +++ b/src/SMAPI/Framework/ModLoading/Rewriters/ArchitectureAssemblyRewriter.cs @@ -1,13 +1,9 @@ -using System; -using HarmonyLib; using Mono.Cecil; -using Mono.Cecil.Cil; using StardewModdingAPI.Framework.ModLoading.Framework; -using StardewModdingAPI.Framework.ModLoading.RewriteFacades; namespace StardewModdingAPI.Framework.ModLoading.Rewriters { - /// Rewrites Harmony 1.x assembly references to work with Harmony 2.x. + /// Removes the 32-bit-only from loaded assemblies. internal class ArchitectureAssemblyRewriter : BaseInstructionHandler { /********* @@ -19,14 +15,15 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters /// - public override bool Handle( ModuleDefinition module ) + public override bool Handle(ModuleDefinition module) { - if ( module.Attributes.HasFlag( ModuleAttributes.Required32Bit ) ) + if (module.Attributes.HasFlag(ModuleAttributes.Required32Bit)) { - module.Attributes = module.Attributes & ~ModuleAttributes.Required32Bit; + module.Attributes &= ~ModuleAttributes.Required32Bit; this.MarkRewritten(); return true; } + return false; } -- cgit