summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI.AssemblyRewriters
diff options
context:
space:
mode:
Diffstat (limited to 'src/StardewModdingAPI.AssemblyRewriters')
-rw-r--r--src/StardewModdingAPI.AssemblyRewriters/Finders/EventFinder.cs83
-rw-r--r--src/StardewModdingAPI.AssemblyRewriters/Finders/FieldFinder.cs83
-rw-r--r--src/StardewModdingAPI.AssemblyRewriters/Finders/MethodFinder.cs83
-rw-r--r--src/StardewModdingAPI.AssemblyRewriters/Finders/PropertyFinder.cs83
-rw-r--r--src/StardewModdingAPI.AssemblyRewriters/Finders/TypeFinder.cs135
-rw-r--r--src/StardewModdingAPI.AssemblyRewriters/IInstructionRewriter.cs38
-rw-r--r--src/StardewModdingAPI.AssemblyRewriters/IncompatibleInstructionException.cs35
-rw-r--r--src/StardewModdingAPI.AssemblyRewriters/Platform.cs12
-rw-r--r--src/StardewModdingAPI.AssemblyRewriters/PlatformAssemblyMap.cs55
-rw-r--r--src/StardewModdingAPI.AssemblyRewriters/Properties/AssemblyInfo.cs7
-rw-r--r--src/StardewModdingAPI.AssemblyRewriters/RewriteHelper.cs94
-rw-r--r--src/StardewModdingAPI.AssemblyRewriters/Rewriters/FieldReplaceRewriter.cs53
-rw-r--r--src/StardewModdingAPI.AssemblyRewriters/Rewriters/FieldToPropertyRewriter.cs54
-rw-r--r--src/StardewModdingAPI.AssemblyRewriters/Rewriters/MethodParentRewriter.cs93
-rw-r--r--src/StardewModdingAPI.AssemblyRewriters/Rewriters/TypeReferenceRewriter.cs157
-rw-r--r--src/StardewModdingAPI.AssemblyRewriters/Rewriters/Wrappers/SpriteBatchWrapper.cs59
-rw-r--r--src/StardewModdingAPI.AssemblyRewriters/StardewModdingAPI.AssemblyRewriters.csproj73
-rw-r--r--src/StardewModdingAPI.AssemblyRewriters/packages.config4
18 files changed, 0 insertions, 1201 deletions
diff --git a/src/StardewModdingAPI.AssemblyRewriters/Finders/EventFinder.cs b/src/StardewModdingAPI.AssemblyRewriters/Finders/EventFinder.cs
deleted file mode 100644
index c0051469..00000000
--- a/src/StardewModdingAPI.AssemblyRewriters/Finders/EventFinder.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-using Mono.Cecil;
-using Mono.Cecil.Cil;
-
-namespace StardewModdingAPI.AssemblyRewriters.Finders
-{
- /// <summary>Finds incompatible CIL instructions that reference a given event and throws an <see cref="IncompatibleInstructionException"/>.</summary>
- public class EventFinder : IInstructionRewriter
- {
- /*********
- ** Properties
- *********/
- /// <summary>The full type name for which to find references.</summary>
- private readonly string FullTypeName;
-
- /// <summary>The event name for which to find references.</summary>
- private readonly string EventName;
-
-
- /*********
- ** Accessors
- *********/
- /// <summary>A brief noun phrase indicating what the instruction finder matches.</summary>
- public string NounPhrase { get; }
-
-
- /*********
- ** Public methods
- *********/
- /// <summary>Construct an instance.</summary>
- /// <param name="fullTypeName">The full type name for which to find references.</param>
- /// <param name="eventName">The event name for which to find references.</param>
- /// <param name="nounPhrase">A brief noun phrase indicating what the instruction finder matches (or <c>null</c> to generate one).</param>
- public EventFinder(string fullTypeName, string eventName, string nounPhrase = null)
- {
- this.FullTypeName = fullTypeName;
- this.EventName = eventName;
- this.NounPhrase = nounPhrase ?? $"{fullTypeName}.{eventName} event";
- }
-
- /// <summary>Rewrite a method definition for compatibility.</summary>
- /// <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)
- {
- return false;
- }
-
- /// <summary>Rewrite a CIL instruction for compatibility.</summary>
- /// <param name="module">The module being rewritten.</param>
- /// <param name="cil">The CIL rewriter.</param>
- /// <param name="instruction">The instruction 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, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged)
- {
- if (!this.IsMatch(instruction))
- return false;
-
- throw new IncompatibleInstructionException(this.NounPhrase);
- }
-
-
- /*********
- ** Protected methods
- *********/
- /// <summary>Get whether a CIL instruction matches.</summary>
- /// <param name="instruction">The IL instruction.</param>
- protected bool IsMatch(Instruction instruction)
- {
- MethodReference methodRef = RewriteHelper.AsMethodReference(instruction);
- return
- methodRef != null
- && methodRef.DeclaringType.FullName == this.FullTypeName
- && (methodRef.Name == "add_" + this.EventName || methodRef.Name == "remove_" + this.EventName);
- }
- }
-}
diff --git a/src/StardewModdingAPI.AssemblyRewriters/Finders/FieldFinder.cs b/src/StardewModdingAPI.AssemblyRewriters/Finders/FieldFinder.cs
deleted file mode 100644
index b44883e9..00000000
--- a/src/StardewModdingAPI.AssemblyRewriters/Finders/FieldFinder.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-using Mono.Cecil;
-using Mono.Cecil.Cil;
-
-namespace StardewModdingAPI.AssemblyRewriters.Finders
-{
- /// <summary>Finds incompatible CIL instructions that reference a given field and throws an <see cref="IncompatibleInstructionException"/>.</summary>
- public class FieldFinder : IInstructionRewriter
- {
- /*********
- ** Properties
- *********/
- /// <summary>The full type name for which to find references.</summary>
- private readonly string FullTypeName;
-
- /// <summary>The field name for which to find references.</summary>
- private readonly string FieldName;
-
-
- /*********
- ** Accessors
- *********/
- /// <summary>A brief noun phrase indicating what the instruction finder matches.</summary>
- public string NounPhrase { get; }
-
-
- /*********
- ** Public methods
- *********/
- /// <summary>Construct an instance.</summary>
- /// <param name="fullTypeName">The full type name for which to find references.</param>
- /// <param name="fieldName">The field name for which to find references.</param>
- /// <param name="nounPhrase">A brief noun phrase indicating what the instruction finder matches (or <c>null</c> to generate one).</param>
- public FieldFinder(string fullTypeName, string fieldName, string nounPhrase = null)
- {
- this.FullTypeName = fullTypeName;
- this.FieldName = fieldName;
- this.NounPhrase = nounPhrase ?? $"{fullTypeName}.{fieldName} field";
- }
-
- /// <summary>Rewrite a method definition for compatibility.</summary>
- /// <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)
- {
- return false;
- }
-
- /// <summary>Rewrite a CIL instruction for compatibility.</summary>
- /// <param name="module">The module being rewritten.</param>
- /// <param name="cil">The CIL rewriter.</param>
- /// <param name="instruction">The instruction 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, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged)
- {
- if (!this.IsMatch(instruction))
- return false;
-
- throw new IncompatibleInstructionException(this.NounPhrase);
- }
-
-
- /*********
- ** Protected methods
- *********/
- /// <summary>Get whether a CIL instruction matches.</summary>
- /// <param name="instruction">The IL instruction.</param>
- protected bool IsMatch(Instruction instruction)
- {
- FieldReference fieldRef = RewriteHelper.AsFieldReference(instruction);
- return
- fieldRef != null
- && fieldRef.DeclaringType.FullName == this.FullTypeName
- && fieldRef.Name == this.FieldName;
- }
- }
-}
diff --git a/src/StardewModdingAPI.AssemblyRewriters/Finders/MethodFinder.cs b/src/StardewModdingAPI.AssemblyRewriters/Finders/MethodFinder.cs
deleted file mode 100644
index 19dda58a..00000000
--- a/src/StardewModdingAPI.AssemblyRewriters/Finders/MethodFinder.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-using Mono.Cecil;
-using Mono.Cecil.Cil;
-
-namespace StardewModdingAPI.AssemblyRewriters.Finders
-{
- /// <summary>Finds incompatible CIL instructions that reference a given method and throws an <see cref="IncompatibleInstructionException"/>.</summary>
- public class MethodFinder : IInstructionRewriter
- {
- /*********
- ** Properties
- *********/
- /// <summary>The full type name for which to find references.</summary>
- private readonly string FullTypeName;
-
- /// <summary>The method name for which to find references.</summary>
- private readonly string MethodName;
-
-
- /*********
- ** Accessors
- *********/
- /// <summary>A brief noun phrase indicating what the instruction finder matches.</summary>
- public string NounPhrase { get; }
-
-
- /*********
- ** Public methods
- *********/
- /// <summary>Construct an instance.</summary>
- /// <param name="fullTypeName">The full type name for which to find references.</param>
- /// <param name="methodName">The method name for which to find references.</param>
- /// <param name="nounPhrase">A brief noun phrase indicating what the instruction finder matches (or <c>null</c> to generate one).</param>
- public MethodFinder(string fullTypeName, string methodName, string nounPhrase = null)
- {
- this.FullTypeName = fullTypeName;
- this.MethodName = methodName;
- this.NounPhrase = nounPhrase ?? $"{fullTypeName}.{methodName} method";
- }
-
- /// <summary>Rewrite a method definition for compatibility.</summary>
- /// <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)
- {
- return false;
- }
-
- /// <summary>Rewrite a CIL instruction for compatibility.</summary>
- /// <param name="module">The module being rewritten.</param>
- /// <param name="cil">The CIL rewriter.</param>
- /// <param name="instruction">The instruction 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, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged)
- {
- if (!this.IsMatch(instruction))
- return false;
-
- throw new IncompatibleInstructionException(this.NounPhrase);
- }
-
-
- /*********
- ** Protected methods
- *********/
- /// <summary>Get whether a CIL instruction matches.</summary>
- /// <param name="instruction">The IL instruction.</param>
- protected bool IsMatch(Instruction instruction)
- {
- MethodReference methodRef = RewriteHelper.AsMethodReference(instruction);
- return
- methodRef != null
- && methodRef.DeclaringType.FullName == this.FullTypeName
- && methodRef.Name == this.MethodName;
- }
- }
-}
diff --git a/src/StardewModdingAPI.AssemblyRewriters/Finders/PropertyFinder.cs b/src/StardewModdingAPI.AssemblyRewriters/Finders/PropertyFinder.cs
deleted file mode 100644
index 441f15f2..00000000
--- a/src/StardewModdingAPI.AssemblyRewriters/Finders/PropertyFinder.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-using Mono.Cecil;
-using Mono.Cecil.Cil;
-
-namespace StardewModdingAPI.AssemblyRewriters.Finders
-{
- /// <summary>Finds incompatible CIL instructions that reference a given property and throws an <see cref="IncompatibleInstructionException"/>.</summary>
- public class PropertyFinder : IInstructionRewriter
- {
- /*********
- ** Properties
- *********/
- /// <summary>The full type name for which to find references.</summary>
- private readonly string FullTypeName;
-
- /// <summary>The property name for which to find references.</summary>
- private readonly string PropertyName;
-
-
- /*********
- ** Accessors
- *********/
- /// <summary>A brief noun phrase indicating what the instruction finder matches.</summary>
- public string NounPhrase { get; }
-
-
- /*********
- ** Public methods
- *********/
- /// <summary>Construct an instance.</summary>
- /// <param name="fullTypeName">The full type name for which to find references.</param>
- /// <param name="propertyName">The property name for which to find references.</param>
- /// <param name="nounPhrase">A brief noun phrase indicating what the instruction finder matches (or <c>null</c> to generate one).</param>
- public PropertyFinder(string fullTypeName, string propertyName, string nounPhrase = null)
- {
- this.FullTypeName = fullTypeName;
- this.PropertyName = propertyName;
- this.NounPhrase = nounPhrase ?? $"{fullTypeName}.{propertyName} property";
- }
-
- /// <summary>Rewrite a method definition for compatibility.</summary>
- /// <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)
- {
- return false;
- }
-
- /// <summary>Rewrite a CIL instruction for compatibility.</summary>
- /// <param name="module">The module being rewritten.</param>
- /// <param name="cil">The CIL rewriter.</param>
- /// <param name="instruction">The instruction 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, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged)
- {
- if (!this.IsMatch(instruction))
- return false;
-
- throw new IncompatibleInstructionException(this.NounPhrase);
- }
-
-
- /*********
- ** Protected methods
- *********/
- /// <summary>Get whether a CIL instruction matches.</summary>
- /// <param name="instruction">The IL instruction.</param>
- protected bool IsMatch(Instruction instruction)
- {
- MethodReference methodRef = RewriteHelper.AsMethodReference(instruction);
- return
- methodRef != null
- && methodRef.DeclaringType.FullName == this.FullTypeName
- && (methodRef.Name == "get_" + this.PropertyName || methodRef.Name == "set_" + this.PropertyName);
- }
- }
-}
diff --git a/src/StardewModdingAPI.AssemblyRewriters/Finders/TypeFinder.cs b/src/StardewModdingAPI.AssemblyRewriters/Finders/TypeFinder.cs
deleted file mode 100644
index 0560e38e..00000000
--- a/src/StardewModdingAPI.AssemblyRewriters/Finders/TypeFinder.cs
+++ /dev/null
@@ -1,135 +0,0 @@
-using System.Linq;
-using Mono.Cecil;
-using Mono.Cecil.Cil;
-
-namespace StardewModdingAPI.AssemblyRewriters.Finders
-{
- /// <summary>Finds incompatible CIL instructions that reference a given type and throws an <see cref="IncompatibleInstructionException"/>.</summary>
- public class TypeFinder : IInstructionRewriter
- {
- /*********
- ** Accessors
- *********/
- /// <summary>The full type name for which to find references.</summary>
- private readonly string FullTypeName;
-
-
- /*********
- ** Accessors
- *********/
- /// <summary>A brief noun phrase indicating what the instruction finder matches.</summary>
- public string NounPhrase { get; }
-
-
- /*********
- ** Public methods
- *********/
- /// <summary>Construct an instance.</summary>
- /// <param name="fullTypeName">The full type name to match.</param>
- /// <param name="nounPhrase">A brief noun phrase indicating what the instruction finder matches (or <c>null</c> to generate one).</param>
- public TypeFinder(string fullTypeName, string nounPhrase = null)
- {
- this.FullTypeName = fullTypeName;
- this.NounPhrase = nounPhrase ?? $"{fullTypeName} type";
- }
-
- /// <summary>Rewrite a method definition for compatibility.</summary>
- /// <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)
- {
- if (!this.IsMatch(method))
- return false;
-
- throw new IncompatibleInstructionException(this.NounPhrase);
- }
-
- /// <summary>Rewrite a CIL instruction for compatibility.</summary>
- /// <param name="module">The module being rewritten.</param>
- /// <param name="cil">The CIL rewriter.</param>
- /// <param name="instruction">The instruction 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, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged)
- {
- if (!this.IsMatch(instruction))
- return false;
-
- throw new IncompatibleInstructionException(this.NounPhrase);
- }
-
-
- /*********
- ** Protected methods
- *********/
- /// <summary>Get whether a CIL instruction matches.</summary>
- /// <param name="method">The method deifnition.</param>
- protected bool IsMatch(MethodDefinition method)
- {
- if (this.IsMatch(method.ReturnType))
- return true;
-
- foreach (VariableDefinition variable in method.Body.Variables)
- {
- if (this.IsMatch(variable.VariableType))
- return true;
- }
-
- return false;
- }
-
- /// <summary>Get whether a CIL instruction matches.</summary>
- /// <param name="instruction">The IL instruction.</param>
- protected bool IsMatch(Instruction instruction)
- {
- // field reference
- FieldReference fieldRef = RewriteHelper.AsFieldReference(instruction);
- if (fieldRef != null)
- {
- return
- this.IsMatch(fieldRef.DeclaringType) // field on target class
- || this.IsMatch(fieldRef.FieldType); // field value is target class
- }
-
- // method reference
- MethodReference methodRef = RewriteHelper.AsMethodReference(instruction);
- if (methodRef != null)
- {
- return
- this.IsMatch(methodRef.DeclaringType) // method on target class
- || this.IsMatch(methodRef.ReturnType) // method returns target class
- || methodRef.Parameters.Any(p => this.IsMatch(p.ParameterType)); // method parameters
- }
-
- return false;
- }
-
- /// <summary>Get whether a type reference matches the expected type.</summary>
- /// <param name="type">The type to check.</param>
- protected bool IsMatch(TypeReference type)
- {
- // root type
- if (type.FullName == this.FullTypeName)
- return true;
-
- // generic arguments
- if (type is GenericInstanceType genericType)
- {
- if (genericType.GenericArguments.Any(this.IsMatch))
- return true;
- }
-
- // generic parameters (e.g. constraints)
- if (type.GenericParameters.Any(this.IsMatch))
- return true;
-
- return false;
- }
- }
-}
diff --git a/src/StardewModdingAPI.AssemblyRewriters/IInstructionRewriter.cs b/src/StardewModdingAPI.AssemblyRewriters/IInstructionRewriter.cs
deleted file mode 100644
index 2f16b23d..00000000
--- a/src/StardewModdingAPI.AssemblyRewriters/IInstructionRewriter.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using Mono.Cecil;
-using Mono.Cecil.Cil;
-
-namespace StardewModdingAPI.AssemblyRewriters
-{
- /// <summary>Rewrites CIL instructions for compatibility.</summary>
- public interface IInstructionRewriter
- {
- /*********
- ** Accessors
- *********/
- /// <summary>A brief noun phrase indicating what the rewriter matches.</summary>
- string NounPhrase { get; }
-
-
- /*********
- ** Methods
- *********/
- /// <summary>Rewrite a method definition for compatibility.</summary>
- /// <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);
-
- /// <summary>Rewrite a CIL instruction for compatibility.</summary>
- /// <param name="module">The module being rewritten.</param>
- /// <param name="cil">The CIL rewriter.</param>
- /// <param name="instruction">The instruction 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, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged);
- }
-}
diff --git a/src/StardewModdingAPI.AssemblyRewriters/IncompatibleInstructionException.cs b/src/StardewModdingAPI.AssemblyRewriters/IncompatibleInstructionException.cs
deleted file mode 100644
index f7e6bd8f..00000000
--- a/src/StardewModdingAPI.AssemblyRewriters/IncompatibleInstructionException.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using System;
-
-namespace StardewModdingAPI.AssemblyRewriters
-{
- /// <summary>An exception raised when an incompatible instruction is found while loading a mod assembly.</summary>
- public class IncompatibleInstructionException : Exception
- {
- /*********
- ** Accessors
- *********/
- /// <summary>A brief noun phrase which describes the incompatible instruction that was found.</summary>
- public string NounPhrase { get; }
-
-
- /*********
- ** Public methods
- *********/
- /// <summary>Construct an instance.</summary>
- /// <param name="nounPhrase">A brief noun phrase which describes the incompatible instruction that was found.</param>
- public IncompatibleInstructionException(string nounPhrase)
- : base($"Found an incompatible CIL instruction ({nounPhrase}).")
- {
- this.NounPhrase = nounPhrase;
- }
-
- /// <summary>Construct an instance.</summary>
- /// <param name="nounPhrase">A brief noun phrase which describes the incompatible instruction that was found.</param>
- /// <param name="message">A message which describes the error.</param>
- public IncompatibleInstructionException(string nounPhrase, string message)
- : base(message)
- {
- this.NounPhrase = nounPhrase;
- }
- }
-}
diff --git a/src/StardewModdingAPI.AssemblyRewriters/Platform.cs b/src/StardewModdingAPI.AssemblyRewriters/Platform.cs
deleted file mode 100644
index 8888a9a8..00000000
--- a/src/StardewModdingAPI.AssemblyRewriters/Platform.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace StardewModdingAPI.AssemblyRewriters
-{
- /// <summary>The game's platform version.</summary>
- public enum Platform
- {
- /// <summary>The Linux/Mac version of the game.</summary>
- Mono,
-
- /// <summary>The Windows version of the game.</summary>
- Windows
- }
-} \ No newline at end of file
diff --git a/src/StardewModdingAPI.AssemblyRewriters/PlatformAssemblyMap.cs b/src/StardewModdingAPI.AssemblyRewriters/PlatformAssemblyMap.cs
deleted file mode 100644
index fce2b187..00000000
--- a/src/StardewModdingAPI.AssemblyRewriters/PlatformAssemblyMap.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using Mono.Cecil;
-
-namespace StardewModdingAPI.AssemblyRewriters
-{
- /// <summary>Metadata for mapping assemblies to the current <see cref="Platform"/>.</summary>
- public class PlatformAssemblyMap
- {
- /*********
- ** Accessors
- *********/
- /****
- ** Data
- ****/
- /// <summary>The target game platform.</summary>
- public readonly Platform TargetPlatform;
-
- /// <summary>The short assembly names to remove as assembly reference, and replace with the <see cref="Targets"/>. These should be short names (like "Stardew Valley").</summary>
- public readonly string[] RemoveNames;
-
- /****
- ** Metadata
- ****/
- /// <summary>The assemblies to target. Equivalent types should be rewritten to use these assemblies.</summary>
- public readonly Assembly[] Targets;
-
- /// <summary>An assembly => reference cache.</summary>
- public readonly IDictionary<Assembly, AssemblyNameReference> TargetReferences;
-
- /// <summary>An assembly => module cache.</summary>
- public readonly IDictionary<Assembly, ModuleDefinition> TargetModules;
-
-
- /*********
- ** Public methods
- *********/
- /// <summary>Construct an instance.</summary>
- /// <param name="targetPlatform">The target game platform.</param>
- /// <param name="removeAssemblyNames">The assembly short names to remove (like <c>Stardew Valley</c>).</param>
- /// <param name="targetAssemblies">The assemblies to target.</param>
- public PlatformAssemblyMap(Platform targetPlatform, string[] removeAssemblyNames, Assembly[] targetAssemblies)
- {
- // save data
- this.TargetPlatform = targetPlatform;
- this.RemoveNames = removeAssemblyNames;
-
- // cache assembly metadata
- this.Targets = targetAssemblies;
- this.TargetReferences = this.Targets.ToDictionary(assembly => assembly, assembly => AssemblyNameReference.Parse(assembly.FullName));
- this.TargetModules = this.Targets.ToDictionary(assembly => assembly, assembly => ModuleDefinition.ReadModule(assembly.Modules.Single().FullyQualifiedName));
- }
- }
-}
diff --git a/src/StardewModdingAPI.AssemblyRewriters/Properties/AssemblyInfo.cs b/src/StardewModdingAPI.AssemblyRewriters/Properties/AssemblyInfo.cs
deleted file mode 100644
index 25fbfef9..00000000
--- a/src/StardewModdingAPI.AssemblyRewriters/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-[assembly: AssemblyTitle("StardewModdingAPI.AssemblyRewriters")]
-[assembly: AssemblyDescription("Contains internal SMAPI code for converting mods between Linux/Mac and Windows. This assembly is used by SMAPI internally and shouldn't be referenced directly by mods.")]
-[assembly: AssemblyProduct("StardewModdingAPI.CrossplatformRewriters")]
-[assembly: Guid("10db0676-9fc1-4771-a2c8-e2519f091e49")]
diff --git a/src/StardewModdingAPI.AssemblyRewriters/RewriteHelper.cs b/src/StardewModdingAPI.AssemblyRewriters/RewriteHelper.cs
deleted file mode 100644
index cfb330dd..00000000
--- a/src/StardewModdingAPI.AssemblyRewriters/RewriteHelper.cs
+++ /dev/null
@@ -1,94 +0,0 @@
-using System;
-using System.Linq;
-using System.Reflection;
-using Mono.Cecil;
-using Mono.Cecil.Cil;
-
-namespace StardewModdingAPI.AssemblyRewriters
-{
- /// <summary>Provides helper methods for field rewriters.</summary>
- internal static class RewriteHelper
- {
- /*********
- ** Public methods
- *********/
- /// <summary>Get the field reference from an instruction if it matches.</summary>
- /// <param name="instruction">The IL instruction.</param>
- public static FieldReference AsFieldReference(Instruction instruction)
- {
- return instruction.OpCode == OpCodes.Ldfld || instruction.OpCode == OpCodes.Ldsfld || instruction.OpCode == OpCodes.Stfld || instruction.OpCode == OpCodes.Stsfld
- ? (FieldReference)instruction.Operand
- : null;
- }
-
- /// <summary>Get the method reference from an instruction if it matches.</summary>
- /// <param name="instruction">The IL instruction.</param>
- public static MethodReference AsMethodReference(Instruction instruction)
- {
- return instruction.OpCode == OpCod