diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-03-04 21:59:49 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-03-04 21:59:49 -0500 |
commit | 5a2258f4194986df3dea7dca9b17cdc96b3e63d5 (patch) | |
tree | bc10126c76c89be0c4fc984c64e732806577a55c /src/SMAPI/Framework | |
parent | 699a07ecf718ee60a1225ff910a73aa4898ef908 (diff) | |
download | SMAPI-5a2258f4194986df3dea7dca9b17cdc96b3e63d5.tar.gz SMAPI-5a2258f4194986df3dea7dca9b17cdc96b3e63d5.tar.bz2 SMAPI-5a2258f4194986df3dea7dca9b17cdc96b3e63d5.zip |
fix RewriteMods option ignored when rewriting mod for OS
Diffstat (limited to 'src/SMAPI/Framework')
-rw-r--r-- | src/SMAPI/Framework/ModLoading/AssemblyLoader.cs | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs index 4fae0f44..69535aa5 100644 --- a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs +++ b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs @@ -276,37 +276,40 @@ namespace StardewModdingAPI.Framework.ModLoading // swap assembly references if needed (e.g. XNA => MonoGame) bool platformChanged = false; - for (int i = 0; i < module.AssemblyReferences.Count; i++) + if (this.RewriteMods) { - // remove old assembly reference - if (this.AssemblyMap.RemoveNames.Any(name => module.AssemblyReferences[i].Name == name)) + for (int i = 0; i < module.AssemblyReferences.Count; i++) { - this.Monitor.LogOnce(loggedMessages, $"{logPrefix}Rewriting {filename} for OS..."); - platformChanged = true; - module.AssemblyReferences.RemoveAt(i); - i--; + // remove old assembly reference + if (this.AssemblyMap.RemoveNames.Any(name => module.AssemblyReferences[i].Name == name)) + { + this.Monitor.LogOnce(loggedMessages, $"{logPrefix}Rewriting {filename} for OS..."); + platformChanged = true; + module.AssemblyReferences.RemoveAt(i); + i--; + } } - } - if (platformChanged) - { - // add target assembly references - foreach (AssemblyNameReference target in this.AssemblyMap.TargetReferences.Values) - module.AssemblyReferences.Add(target); + if (platformChanged) + { + // add target assembly references + foreach (AssemblyNameReference target in this.AssemblyMap.TargetReferences.Values) + module.AssemblyReferences.Add(target); - // rewrite type scopes to use target assemblies - IEnumerable<TypeReference> typeReferences = module.GetTypeReferences().OrderBy(p => p.FullName); - foreach (TypeReference type in typeReferences) - this.ChangeTypeScope(type); + // rewrite type scopes to use target assemblies + IEnumerable<TypeReference> typeReferences = module.GetTypeReferences().OrderBy(p => p.FullName); + foreach (TypeReference type in typeReferences) + this.ChangeTypeScope(type); - // rewrite types using custom attributes - foreach (TypeDefinition type in module.GetTypes()) - { - foreach (var attr in type.CustomAttributes) + // rewrite types using custom attributes + foreach (TypeDefinition type in module.GetTypes()) { - foreach (var conField in attr.ConstructorArguments) + foreach (var attr in type.CustomAttributes) { - if (conField.Value is TypeReference typeRef) - this.ChangeTypeScope(typeRef); + foreach (var conField in attr.ConstructorArguments) + { + if (conField.Value is TypeReference typeRef) + this.ChangeTypeScope(typeRef); + } } } } |