summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI
diff options
context:
space:
mode:
Diffstat (limited to 'src/StardewModdingAPI')
-rw-r--r--src/StardewModdingAPI/Framework/ModLoading/AssemblyLoader.cs14
-rw-r--r--src/StardewModdingAPI/Framework/ModLoading/Finders/EventFinder.cs6
-rw-r--r--src/StardewModdingAPI/Framework/ModLoading/Finders/FieldFinder.cs6
-rw-r--r--src/StardewModdingAPI/Framework/ModLoading/Finders/MethodFinder.cs6
-rw-r--r--src/StardewModdingAPI/Framework/ModLoading/Finders/PropertyFinder.cs6
-rw-r--r--src/StardewModdingAPI/Framework/ModLoading/Finders/TypeFinder.cs6
-rw-r--r--src/StardewModdingAPI/Framework/ModLoading/IInstructionRewriter.cs6
-rw-r--r--src/StardewModdingAPI/Framework/ModLoading/Rewriters/FieldReplaceRewriter.cs3
-rw-r--r--src/StardewModdingAPI/Framework/ModLoading/Rewriters/FieldToPropertyRewriter.cs3
-rw-r--r--src/StardewModdingAPI/Framework/ModLoading/Rewriters/MethodParentRewriter.cs6
-rw-r--r--src/StardewModdingAPI/Framework/ModLoading/Rewriters/TypeReferenceRewriter.cs6
-rw-r--r--src/StardewModdingAPI/Program.cs2
12 files changed, 45 insertions, 25 deletions
diff --git a/src/StardewModdingAPI/Framework/ModLoading/AssemblyLoader.cs b/src/StardewModdingAPI/Framework/ModLoading/AssemblyLoader.cs
index 01dc602a..f9c43f1f 100644
--- a/src/StardewModdingAPI/Framework/ModLoading/AssemblyLoader.cs
+++ b/src/StardewModdingAPI/Framework/ModLoading/AssemblyLoader.cs
@@ -53,11 +53,12 @@ namespace StardewModdingAPI.Framework.ModLoading
}
/// <summary>Preprocess and load an assembly.</summary>
+ /// <param name="mod">The mod for which the assembly is being loaded.</param>
/// <param name="assemblyPath">The assembly file path.</param>
/// <param name="assumeCompatible">Assume the mod is compatible, even if incompatible code is detected.</param>
/// <returns>Returns the rewrite metadata for the preprocessed assembly.</returns>
/// <exception cref="IncompatibleInstructionException">An incompatible CIL instruction was found while rewriting the assembly.</exception>
- public Assembly Load(string assemblyPath, bool assumeCompatible)
+ public Assembly Load(IModMetadata mod, string assemblyPath, bool assumeCompatible)
{
// get referenced local assemblies
AssemblyParseResult[] assemblies;
@@ -86,7 +87,7 @@ namespace StardewModdingAPI.Framework.ModLoading
if (assembly.Status == AssemblyLoadStatus.AlreadyLoaded)
continue;
- bool changed = this.RewriteAssembly(assembly.Definition, assumeCompatible, logPrefix: " ");
+ bool changed = this.RewriteAssembly(mod, assembly.Definition, assumeCompatible, logPrefix: " ");
if (changed)
{
if (!oneAssembly)
@@ -173,12 +174,13 @@ namespace StardewModdingAPI.Framework.ModLoading
** Assembly rewriting
****/
/// <summary>Rewrite the types referenced by an assembly.</summary>
+ /// <param name="mod">The mod for which the assembly is being loaded.</param>
/// <param name="assembly">The assembly to rewrite.</param>
/// <param name="assumeCompatible">Assume the mod is compatible, even if incompatible code is detected.</param>
/// <param name="logPrefix">A string to prefix to log messages.</param>
/// <returns>Returns whether the assembly was modified.</returns>
/// <exception cref="IncompatibleInstructionException">An incompatible CIL instruction was found while rewriting the assembly.</exception>
- private bool RewriteAssembly(AssemblyDefinition assembly, bool assumeCompatible, string logPrefix)
+ private bool RewriteAssembly(IModMetadata mod, AssemblyDefinition assembly, bool assumeCompatible, string logPrefix)
{
ModuleDefinition module = assembly.MainModule;
HashSet<string> loggedMessages = new HashSet<string>();
@@ -211,7 +213,7 @@ namespace StardewModdingAPI.Framework.ModLoading
// find (and optionally rewrite) incompatible instructions
bool anyRewritten = false;
- IInstructionRewriter[] rewriters = Constants.GetRewriters().ToArray();
+ IInstructionRewriter[] rewriters = Constants.GetRewriters(this.Monitor).ToArray();
foreach (MethodDefinition method in this.GetMethods(module))
{
// check method definition
@@ -219,7 +221,7 @@ namespace StardewModdingAPI.Framework.ModLoading
{
try
{
- if (rewriter.Rewrite(module, method, this.AssemblyMap, platformChanged))
+ if (rewriter.Rewrite(mod, module, method, this.AssemblyMap, platformChanged))
{
this.Monitor.LogOnce(loggedMessages, $"{logPrefix}Rewrote {filename} to fix {rewriter.NounPhrase}...");
anyRewritten = true;
@@ -241,7 +243,7 @@ namespace StardewModdingAPI.Framework.ModLoading
{
try
{
- if (rewriter.Rewrite(module, cil, instruction, this.AssemblyMap, platformChanged))
+ if (rewriter.Rewrite(mod, module, cil, instruction, this.AssemblyMap, platformChanged))
{
this.Monitor.LogOnce(loggedMessages, $"{logPrefix}Rewrote {filename} to fix {rewriter.NounPhrase}...");
anyRewritten = true;
diff --git a/src/StardewModdingAPI/Framework/ModLoading/Finders/EventFinder.cs b/src/StardewModdingAPI/Framework/ModLoading/Finders/EventFinder.cs
index ce234e39..ac5034c4 100644
--- a/src/StardewModdingAPI/Framework/ModLoading/Finders/EventFinder.cs
+++ b/src/StardewModdingAPI/Framework/ModLoading/Finders/EventFinder.cs
@@ -38,18 +38,20 @@ namespace StardewModdingAPI.Framework.ModLoading.Finders
}
/// <summary>Rewrite a method definition for compatibility.</summary>
+ /// <param name="mod">The mod to which the module belongs.</param>
/// <param name="module">The module being rewritten.</param>
/// <param name="method">The method definition to rewrite.</param>
/// <param name="assemblyMap">Metadata for mapping assemblies to the current platform.</param>
/// <param name="platformChanged">Whether the mod was compiled on a different platform.</param>
/// <returns>Returns whether the instruction was rewritten.</returns>
/// <exception cref="IncompatibleInstructionException">The CIL instruction is not compatible, and can't be rewritten.</exception>
- public virtual bool Rewrite(ModuleDefinition module, MethodDefinition method, PlatformAssemblyMap assemblyMap, bool platformChanged)
+ public virtual bool Rewrite(IModMetadata mod, ModuleDefinition module, MethodDefinition method, PlatformAssemblyMap assemblyMap, bool platformChanged)
{
return false;
}
/// <summary>Rewrite a CIL instruction for compatibility.</summary>
+ /// <param name="mod">The mod to which the module belongs.</param>
/// <param name="module">The module being rewritten.</param>
/// <param name="cil">The CIL rewriter.</param>
/// <param name="instruction">The instruction to rewrite.</param>
@@ -57,7 +59,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Finders
/// <param name="platformChanged">Whether the mod was compiled on a different platform.</param>
/// <returns>Returns whether the instruction was rewritten.</returns>
/// <exception cref="IncompatibleInstructionException">The CIL instruction is not compatible, and can't be rewritten.</exception>
- public virtual bool Rewrite(ModuleDefinition module, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged)
+ public virtual bool Rewrite(IModMetadata mod, ModuleDefinition module, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged)
{
if (!this.IsMatch(instruction))
return false;
diff --git a/src/StardewModdingAPI/Framework/ModLoading/Finders/FieldFinder.cs b/src/StardewModdingAPI/Framework/ModLoading/Finders/FieldFinder.cs
index 2feaf2e6..008399d5 100644
--- a/src/StardewModdingAPI/Framework/ModLoading/Finders/FieldFinder.cs
+++ b/src/StardewModdingAPI/Framework/ModLoading/Finders/FieldFinder.cs
@@ -38,18 +38,20 @@ namespace StardewModdingAPI.Framework.ModLoading.Finders
}
/// <summary>Rewrite a method definition for compatibility.</summary>
+ /// <param name="mod">The mod to which the module belongs.</param>
/// <param name="module">The module being rewritten.</param>
/// <param name="method">The method definition to rewrite.</param>
/// <param name="assemblyMap">Metadata for mapping assemblies to the current platform.</param>
/// <param name="platformChanged">Whether the mod was compiled on a different platform.</param>
/// <returns>Returns whether the instruction was rewritten.</returns>
/// <exception cref="IncompatibleInstructionException">The CIL instruction is not compatible, and can't be rewritten.</exception>
- public virtual bool Rewrite(ModuleDefinition module, MethodDefinition method, PlatformAssemblyMap assemblyMap, bool platformChanged)
+ public virtual bool Rewrite(IModMetadata mod, ModuleDefinition module, MethodDefinition method, PlatformAssemblyMap assemblyMap, bool platformChanged)
{
return false;
}
/// <summary>Rewrite a CIL instruction for compatibility.</summary>
+ /// <param name="mod">The mod to which the module belongs.</param>
/// <param name="module">The module being rewritten.</param>
/// <param name="cil">The CIL rewriter.</param>
/// <param name="instruction">The instruction to rewrite.</param>
@@ -57,7 +59,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Finders
/// <param name="platformChanged">Whether the mod was compiled on a different platform.</param>
/// <returns>Returns whether the instruction was rewritten.</returns>
/// <exception cref="IncompatibleInstructionException">The CIL instruction is not compatible, and can't be rewritten.</exception>
- public virtual bool Rewrite(ModuleDefinition module, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged)
+ public virtual bool Rewrite(IModMetadata mod, ModuleDefinition module, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged)
{
if (!this.IsMatch(instruction))
return false;
diff --git a/src/StardewModdingAPI/Framework/ModLoading/Finders/MethodFinder.cs b/src/StardewModdingAPI/Framework/ModLoading/Finders/MethodFinder.cs
index c3bb36e3..2a6dc99e 100644
--- a/src/StardewModdingAPI/Framework/ModLoading/Finders/MethodFinder.cs
+++ b/src/StardewModdingAPI/Framework/ModLoading/Finders/MethodFinder.cs
@@ -38,18 +38,20 @@ namespace StardewModdingAPI.Framework.ModLoading.Finders
}
/// <summary>Rewrite a method definition for compatibility.</summary>
+ /// <param name="mod">The mod to which the module belongs.</param>
/// <param name="module">The module being rewritten.</param>
/// <param name="method">The method definition to rewrite.</param>
/// <param name="assemblyMap">Metadata for mapping assemblies to the current platform.</param>
/// <param name="platformChanged">Whether the mod was compiled on a different platform.</param>
/// <returns>Returns whether the instruction was rewritten.</returns>
/// <exception cref="IncompatibleInstructionException">The CIL instruction is not compatible, and can't be rewritten.</exception>
- public virtual bool Rewrite(ModuleDefinition module, MethodDefinition method, PlatformAssemblyMap assemblyMap, bool platformChanged)
+ public virtual bool Rewrite(IModMetadata mod, ModuleDefinition module, MethodDefinition method, PlatformAssemblyMap assemblyMap, bool platformChanged)
{
return false;
}
/// <summary>Rewrite a CIL instruction for compatibility.</summary>
+ /// <param name="mod">The mod to which the module belongs.</param>
/// <param name="module">The module being rewritten.</param>
/// <param name="cil">The CIL rewriter.</param>
/// <param name="instruction">The instruction to rewrite.</param>
@@ -57,7 +59,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Finders
/// <param name="platformChanged">Whether the mod was compiled on a different platform.</param>
/// <returns>Returns whether the instruction was rewritten.</returns>
/// <exception cref="IncompatibleInstructionException">The CIL instruction is not compatible, and can't be rewritten.</exception>
- public bool Rewrite(ModuleDefinition module, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged)
+ public bool Rewrite(IModMetadata mod, ModuleDefinition module, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged)
{
if (!this.IsMatch(instruction))
return false;
diff --git a/src/StardewModdingAPI/Framework/ModLoading/Finders/PropertyFinder.cs b/src/StardewModdingAPI/Framework/ModLoading/Finders/PropertyFinder.cs
index d1fed84b..a0ce1cbf 100644
--- a/src/StardewModdingAPI/Framework/ModLoading/Finders/PropertyFinder.cs
+++ b/src/StardewModdingAPI/Framework/ModLoading/Finders/PropertyFinder.cs
@@ -38,18 +38,20 @@ namespace StardewModdingAPI.Framework.ModLoading.Finders
}
/// <summary>Rewrite a method definition for compatibility.</summary>
+ /// <param name="mod">The mod to which the module belongs.</param>
/// <param name="module">The module being rewritten.</param>
/// <param name="method">The method definition to rewrite.</param>
/// <param name="assemblyMap">Metadata for mapping assemblies to the current platform.</param>
/// <param name="platformChanged">Whether the mod was compiled on a different platform.</param>
/// <returns>Returns whether the instruction was rewritten.</returns>
/// <exception cref="IncompatibleInstructionException">The CIL instruction is not compatible, and can't be rewritten.</exception>
- public virtual bool Rewrite(ModuleDefinition module, MethodDefinition method, PlatformAssemblyMap assemblyMap, bool platformChanged)
+ public virtual bool Rewrite(IModMetadata mod, ModuleDefinition module, MethodDefinition method, PlatformAssemblyMap assemblyMap, bool platformChanged)
{
return false;
}
/// <summary>Rewrite a CIL instruction for compatibility.</summary>
+ /// <param name="mod">The mod to which the module belongs.</param>
/// <param name="module">The module being rewritten.</param>
/// <param name="cil">The CIL rewriter.</param>
/// <param name="instruction">The instruction to rewrite.</param>
@@ -57,7 +59,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Finders
/// <param name="platformChanged">Whether the mod was compiled on a different platform.</param>
/// <returns>Returns whether the instruction was rewritten.</returns>
/// <exception cref="IncompatibleInstructionException">The CIL instruction is not compatible, and can't be rewritten.</exception>
- public virtual bool Rewrite(ModuleDefinition module, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged)
+ public virtual bool Rewrite(IModMetadata mod, ModuleDefinition module, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged)
{
if (!this.IsMatch(instruction))
return false;
diff --git a/src/StardewModdingAPI/Framework/ModLoading/Finders/TypeFinder.cs b/src/StardewModdingAPI/Framework/ModLoading/Finders/TypeFinder.cs
index e67e6766..a3005c85 100644
--- a/src/StardewModdingAPI/Framework/ModLoading/Finders/TypeFinder.cs
+++ b/src/StardewModdingAPI/Framework/ModLoading/Finders/TypeFinder.cs
@@ -34,13 +34,14 @@ namespace StardewModdingAPI.Framework.ModLoading.Finders
}
/// <summary>Rewrite a method definition for compatibility.</summary>
+ /// <param name="mod">The mod to which the module belongs.</param>
/// <param name="module">The module being rewritten.</param>
/// <param name="method">The method definition to rewrite.</param>
/// <param name="assemblyMap">Metadata for mapping assemblies to the current platform.</param>
/// <param name="platformChanged">Whether the mod was compiled on a different platform.</param>
/// <returns>Returns whether the instruction was rewritten.</returns>
/// <exception cref="IncompatibleInstructionException">The CIL instruction is not compatible, and can't be rewritten.</exception>
- public virtual bool Rewrite(ModuleDefinition module, MethodDefinition method, PlatformAssemblyMap assemblyMap, bool platformChanged)
+ public virtual bool Rewrite(IModMetadata mod, ModuleDefinition module, MethodDefinition method, PlatformAssemblyMap assemblyMap, bool platformChanged)
{
if (!this.IsMatch(method))
return false;
@@ -49,6 +50,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Finders
}
/// <summary>Rewrite a CIL instruction for compatibility.</summary>
+ /// <param name="mod">The mod to which the module belongs.</param>
/// <param name="module">The module being rewritten.</param>
/// <param name="cil">The CIL rewriter.</param>
/// <param name="instruction">The instruction to rewrite.</param>
@@ -56,7 +58,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Finders
/// <param name="platformChanged">Whether the mod was compiled on a different platform.</param>
/// <returns>Returns whether the instruction was rewritten.</returns>
/// <exception cref="IncompatibleInstructionException">The CIL instruction is not compatible, and can't be rewritten.</exception>
- public virtual bool Rewrite(ModuleDefinition module, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged)
+ public virtual bool Rewrite(IModMetadata mod, ModuleDefinition module, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged)
{
if (!this.IsMatch(instruction))
return false;
diff --git a/src/StardewModdingAPI/Framework/ModLoading/IInstructionRewriter.cs b/src/StardewModdingAPI/Framework/ModLoading/IInstructionRewriter.cs
index 9b35cdae..ce12c717 100644
--- a/src/StardewModdingAPI/Framework/ModLoading/IInstructionRewriter.cs
+++ b/src/StardewModdingAPI/Framework/ModLoading/IInstructionRewriter.cs
@@ -17,15 +17,17 @@ namespace StardewModdingAPI.Framework.ModLoading
** Methods
*********/
/// <summary>Rewrite a method definition for compatibility.</summary>
+ /// <param name="mod">The mod to which the module belongs.</param>
/// <param name="module">The module being rewritten.</param>
/// <param name="method">The method definition to rewrite.</param>
/// <param name="assemblyMap">Metadata for mapping assemblies to the current platform.</param>
/// <param name="platformChanged">Whether the mod was compiled on a different platform.</param>
/// <returns>Returns whether the instruction was rewritten.</returns>
/// <exception cref="IncompatibleInstructionException">The CIL instruction is not compatible, and can't be rewritten.</exception>
- bool Rewrite(ModuleDefinition module, MethodDefinition method, PlatformAssemblyMap assemblyMap, bool platformChanged);
+ bool Rewrite(IModMetadata mod, ModuleDefinition module, MethodDefinition method, PlatformAssemblyMap assemblyMap, bool platformChanged);
/// <summary>Rewrite a CIL instruction for compatibility.</summary>
+ /// <param name="mod">The mod to which the module belongs.</param>
/// <param name="module">The module being rewritten.</param>
/// <param name="cil">The CIL rewriter.</param>
/// <param name="instruction">The instruction to rewrite.</param>
@@ -33,6 +35,6 @@ namespace StardewModdingAPI.Framework.ModLoading
/// <param name="platformChanged">Whether the mod was compiled on a different platform.</param>
/// <returns>Returns whether the instruction was rewritten.</returns>
/// <exception cref="IncompatibleInstructionException">The CIL instruction is not compatible, and can't be rewritten.</exception>
- bool Rewrite(ModuleDefinition module, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged);
+ bool Rewrite(IModMetadata mod, ModuleDefinition module, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged);
}
}
diff --git a/src/StardewModdingAPI/Framework/ModLoading/Rewriters/FieldReplaceRewriter.cs b/src/StardewModdingAPI/Framework/ModLoading/Rewriters/FieldReplaceRewriter.cs
index 7b838f13..fb2a9a96 100644
--- a/src/StardewModdingAPI/Framework/ModLoading/Rewriters/FieldReplaceRewriter.cs
+++ b/src/StardewModdingAPI/Framework/ModLoading/Rewriters/FieldReplaceRewriter.cs
@@ -33,6 +33,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters
}
/// <summary>Rewrite a CIL instruction for compatibility.</summary>
+ /// <param name="mod">The mod to which the module belongs.</param>
/// <param name="module">The module being rewritten.</param>
/// <param name="cil">The CIL rewriter.</param>
/// <param name="instruction">The instruction to rewrite.</param>
@@ -40,7 +41,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters
/// <param name="platformChanged">Whether the mod was compiled on a different platform.</param>
/// <returns>Returns whether the instruction was rewritten.</returns>
/// <exception cref="IncompatibleInstructionException">The CIL instruction is not compatible, and can't be rewritten.</exception>
- public override bool Rewrite(ModuleDefinition module, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged)
+ public override bool Rewrite(IModMetadata mod, ModuleDefinition module, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged)
{
if (!this.IsMatch(instruction))
return false;
diff --git a/src/StardewModdingAPI/Framework/ModLoading/Rewriters/FieldToPropertyRewriter.cs b/src/StardewModdingAPI/Framework/ModLoading/Rewriters/FieldToPropertyRewriter.cs
index 8ef14103..03d1f707 100644
--- a/src/StardewModdingAPI/Framework/ModLoading/Rewriters/FieldToPropertyRewriter.cs
+++ b/src/StardewModdingAPI/Framework/ModLoading/Rewriters/FieldToPropertyRewriter.cs
@@ -33,6 +33,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters
}
/// <summary>Rewrite a CIL instruction for compatibility.</summary>
+ /// <param name="mod">The mod to which the module belongs.</param>
/// <param name="module">The module being rewritten.</param>
/// <param name="cil">The CIL rewriter.</param>
/// <param name="instruction">The instruction to rewrite.</param>
@@ -40,7 +41,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters
/// <param name="platformChanged">Whether the mod was compiled on a different platform.</param>
/// <returns>Returns whether the instruction was rewritten.</returns>
/// <exception cref="IncompatibleInstructionException">The CIL instruction is not compatible, and can't be rewritten.</exception>
- public override bool Rewrite(ModuleDefinition module, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged)
+ public override bool Rewrite(IModMetadata mod, ModuleDefinition module, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged)
{
if (!this.IsMatch(instruction))
return false;
diff --git a/src/StardewModdingAPI/Framework/ModLoading/Rewriters/MethodParentRewriter.cs b/src/StardewModdingAPI/Framework/ModLoading/Rewriters/MethodParentRewriter.cs
index 1b95b83b..1e116e1f 100644
--- a/src/StardewModdingAPI/Framework/ModLoading/Rewriters/MethodParentRewriter.cs
+++ b/src/StardewModdingAPI/Framework/ModLoading/Rewriters/MethodParentRewriter.cs
@@ -44,18 +44,20 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters
}
/// <summary>Rewrite a method definition for compatibility.</summary>
+ /// <param name="mod">The mod to which the module belongs.</param>
/// <param name="module">The module being rewritten.</param>
/// <param name="method">The method definition to rewrite.</param>
/// <param name="assemblyMap">Metadata for mapping assemblies to the current platform.</param>
/// <param name="platformChanged">Whether the mod was compiled on a different platform.</param>
/// <returns>Returns whether the instruction was rewritten.</returns>
/// <exception cref="IncompatibleInstructionException">The CIL instruction is not compatible, and can't be rewritten.</exception>
- public bool Rewrite(ModuleDefinition module, MethodDefinition method, PlatformAssemblyMap assemblyMap, bool platformChanged)
+ public bool Rewrite(IModMetadata mod, ModuleDefinition module, MethodDefinition method, PlatformAssemblyMap assemblyMap, bool platformChanged)
{
return false;
}
/// <summary>Rewrite a CIL instruction for compatibility.</summary>
+ /// <param name="mod">The mod to which the module belongs.</param>
/// <param name="module">The module being rewritten.</param>
/// <param name="cil">The CIL rewriter.</param>
/// <param name="instruction">The instruction to rewrite.</param>
@@ -63,7 +65,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters
/// <param name="platformChanged">Whether the mod was compiled on a different platform.</param>
/// <returns>Returns whether the instruction was rewritten.</returns>
/// <exception cref="IncompatibleInstructionException">The CIL instruction is not compatible, and can't be rewritten.</exception>
- public bool Rewrite(ModuleDefinition module, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged)
+ public bool Rewrite(IModMetadata mod, ModuleDefinition module, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged)
{
if (!this.IsMatch(instruction, platformChanged))
return false;
diff --git a/src/StardewModdingAPI/Framework/ModLoading/Rewriters/TypeReferenceRewriter.cs b/src/StardewModdingAPI/Framework/ModLoading/Rewriters/TypeReferenceRewriter.cs
index 2c444b64..8db39cfe 100644
--- a/src/StardewModdingAPI/Framework/ModLoading/Rewriters/TypeReferenceRewriter.cs
+++ b/src/StardewModdingAPI/Framework/ModLoading/Rewriters/TypeReferenceRewriter.cs
@@ -33,13 +33,14 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters
}
/// <summary>Rewrite a method definition for compatibility.</summary>
+ /// <param name="mod">The mod to which the module belongs.</param>
/// <param name="module">The module being rewritten.</param>
/// <param name="method">The method definition to rewrite.</param>
/// <param name="assemblyMap">Metadata for mapping assemblies to the current platform.</param>
/// <param name="platformChanged">Whether the mod was compiled on a different platform.</param>
/// <returns>Returns whether the instruction was rewritten.</returns>
/// <exception cref="IncompatibleInstructionException">The CIL instruction is not compatible, and can't be rewritten.</exception>
- public override bool Rewrite(ModuleDefinition module, MethodDefinition method, PlatformAssemblyMap assemblyMap, bool platformChanged)
+ public override bool Rewrite(IModMetadata mod, ModuleDefinition module, MethodDefinition method, PlatformAssemblyMap assemblyMap, bool platformChanged)
{
bool rewritten = false;
@@ -87,6 +88,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters
}
/// <summary>Rewrite a CIL instruction for compatibility.</summary>
+ /// <param name="mod">The mod to which the module belongs.</param>
/// <param name="module">The module being rewritten.</param>
/// <param name="cil">The CIL rewriter.</param>
/// <param name="instruction">The instruction to rewrite.</param>
@@ -94,7 +96,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters
/// <param name="platformChanged">Whether the mod was compiled on a different platform.</param>
/// <returns>Returns whether the instruction was rewritten.</returns>
/// <exception cref="IncompatibleInstructionException">The CIL instruction is not compatible, and can't be rewritten.</exception>
- public override bool Rewrite(ModuleDefinition module, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged)
+ public override bool Rewrite(IModMetadata mod, ModuleDefinition module, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged)
{
if (!this.IsMatch(instruction) && !instruction.ToString().Contains(this.FromTypeName))
return false;
diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs
index c1165216..84af2777 100644
--- a/src/StardewModdingAPI/Program.cs
+++ b/src/StardewModdingAPI/Program.cs
@@ -645,7 +645,7 @@ namespace StardewModdingAPI
Assembly modAssembly;
try
{
- modAssembly = modAssemblyLoader.Load(assemblyPath, assumeCompatible: metadata.Compatibility?.Compatibility == ModCompatibilityType.AssumeCompatible);
+ modAssembly = modAssemblyLoader.Load(metadata, assemblyPath, assumeCompatible: metadata.Compatibility?.Compatibility == ModCompatibilityType.AssumeCompatible);
}
catch (IncompatibleInstructionException ex)
{