summaryrefslogtreecommitdiff
path: root/src/SMAPI/Metadata
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-08-31 01:13:22 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-09-01 20:02:58 -0400
commit8bfab94213e86c4245961150bd3423ee85213c5d (patch)
tree69fb8ceab3a0c21a27a2ac28eb6c42333b1bcf9b /src/SMAPI/Metadata
parentc6cc1513c5ab5544094fe30b13ee0d73e1e04109 (diff)
downloadSMAPI-8bfab94213e86c4245961150bd3423ee85213c5d.tar.gz
SMAPI-8bfab94213e86c4245961150bd3423ee85213c5d.tar.bz2
SMAPI-8bfab94213e86c4245961150bd3423ee85213c5d.zip
reduce unneeded operations when scanning/rewriting mod DLLs
Diffstat (limited to 'src/SMAPI/Metadata')
-rw-r--r--src/SMAPI/Metadata/InstructionMetadata.cs36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/SMAPI/Metadata/InstructionMetadata.cs b/src/SMAPI/Metadata/InstructionMetadata.cs
index 9f537c92..44d906ea 100644
--- a/src/SMAPI/Metadata/InstructionMetadata.cs
+++ b/src/SMAPI/Metadata/InstructionMetadata.cs
@@ -18,7 +18,7 @@ namespace StardewModdingAPI.Metadata
*********/
/// <summary>The assembly names to which to heuristically detect broken references.</summary>
/// <remarks>The current implementation only works correctly with assemblies that should always be present.</remarks>
- private readonly string[] ValidateReferencesToAssemblies = { "StardewModdingAPI", "Stardew Valley", "StardewValley", "Netcode" };
+ private readonly ISet<string> ValidateReferencesToAssemblies = new HashSet<string> { "StardewModdingAPI", "Stardew Valley", "StardewValley", "Netcode" };
/*********
@@ -48,14 +48,16 @@ namespace StardewModdingAPI.Metadata
yield return new HeuristicFieldRewriter(this.ValidateReferencesToAssemblies);
yield return new HeuristicMethodRewriter(this.ValidateReferencesToAssemblies);
- // rewrite for SMAPI 3.12 (Harmony 1.x => 2.0 update)
- yield return new Harmony1AssemblyRewriter();
+ // detect Harmony & rewrite for SMAPI 3.12 (Harmony 1.x => 2.0 update)
+ yield return new HarmonyRewriter();
// rewrite for 64-bit mode
#if SMAPI_FOR_WINDOWS_64BIT_HACK
yield return new ArchitectureAssemblyRewriter();
#endif
}
+ else
+ yield return new HarmonyRewriter(shouldRewrite: false);
/****
** detect mod issues
@@ -67,13 +69,9 @@ namespace StardewModdingAPI.Metadata
/****
** detect code which may impact game stability
****/
- yield return new TypeFinder(typeof(HarmonyLib.Harmony).FullName, InstructionHandleResult.DetectedGamePatch);
yield return new TypeFinder("System.Runtime.CompilerServices.CallSite", InstructionHandleResult.DetectedDynamic);
- yield return new FieldFinder(typeof(SaveGame).FullName, nameof(SaveGame.serializer), InstructionHandleResult.DetectedSaveSerializer);
- yield return new FieldFinder(typeof(SaveGame).FullName, nameof(SaveGame.farmerSerializer), InstructionHandleResult.DetectedSaveSerializer);
- yield return new FieldFinder(typeof(SaveGame).FullName, nameof(SaveGame.locationSerializer), InstructionHandleResult.DetectedSaveSerializer);
- yield return new EventFinder(typeof(ISpecializedEvents).FullName, nameof(ISpecializedEvents.UnvalidatedUpdateTicked), InstructionHandleResult.DetectedUnvalidatedUpdateTick);
- yield return new EventFinder(typeof(ISpecializedEvents).FullName, nameof(ISpecializedEvents.UnvalidatedUpdateTicking), InstructionHandleResult.DetectedUnvalidatedUpdateTick);
+ yield return new FieldFinder(typeof(SaveGame).FullName, new[] { nameof(SaveGame.serializer), nameof(SaveGame.farmerSerializer), nameof(SaveGame.locationSerializer) }, InstructionHandleResult.DetectedSaveSerializer);
+ yield return new EventFinder(typeof(ISpecializedEvents).FullName, new[] { nameof(ISpecializedEvents.UnvalidatedUpdateTicked), nameof(ISpecializedEvents.UnvalidatedUpdateTicking) }, InstructionHandleResult.DetectedUnvalidatedUpdateTick);
/****
** detect paranoid issues
@@ -82,13 +80,19 @@ namespace StardewModdingAPI.Metadata
{
// filesystem access
yield return new TypeFinder(typeof(System.Console).FullName, InstructionHandleResult.DetectedConsoleAccess);
- yield return new TypeFinder(typeof(System.IO.File).FullName, InstructionHandleResult.DetectedFilesystemAccess);
- yield return new TypeFinder(typeof(System.IO.FileStream).FullName, InstructionHandleResult.DetectedFilesystemAccess);
- yield return new TypeFinder(typeof(System.IO.FileInfo).FullName, InstructionHandleResult.DetectedFilesystemAccess);
- yield return new TypeFinder(typeof(System.IO.Directory).FullName, InstructionHandleResult.DetectedFilesystemAccess);
- yield return new TypeFinder(typeof(System.IO.DirectoryInfo).FullName, InstructionHandleResult.DetectedFilesystemAccess);
- yield return new TypeFinder(typeof(System.IO.DriveInfo).FullName, InstructionHandleResult.DetectedFilesystemAccess);
- yield return new TypeFinder(typeof(System.IO.FileSystemWatcher).FullName, InstructionHandleResult.DetectedFilesystemAccess);
+ yield return new TypeFinder(
+ new[]
+ {
+ typeof(System.IO.File).FullName,
+ typeof(System.IO.FileStream).FullName,
+ typeof(System.IO.FileInfo).FullName,
+ typeof(System.IO.Directory).FullName,
+ typeof(System.IO.DirectoryInfo).FullName,
+ typeof(System.IO.DriveInfo).FullName,
+ typeof(System.IO.FileSystemWatcher).FullName
+ },
+ InstructionHandleResult.DetectedFilesystemAccess
+ );
// shell access
yield return new TypeFinder(typeof(System.Diagnostics.Process).FullName, InstructionHandleResult.DetectedShellAccess);