ソースを参照

Fix assemblydefinition not disposing when not used

Bepis 6 年 前
コミット
9782180a21
1 ファイル変更9 行追加7 行削除
  1. 9 7
      BepInEx/Bootstrap/AssemblyPatcher.cs

+ 9 - 7
BepInEx/Bootstrap/AssemblyPatcher.cs

@@ -60,19 +60,21 @@ namespace BepInEx.Bootstrap
             //call the patchers on the assemblies
             foreach (var assembly in sortedAssemblies)
             {
-                //skip if we aren't patching it
-                if (!patcherMethodDictionary.TryGetValue(Path.GetFileName(assemblyFilenames[assembly]), out IList<AssemblyPatcherDelegate> patcherMethods))
-                    continue;
+#if CECIL_10
+                using (assembly)
+#endif
+                {
+                    //skip if we aren't patching it
+                    if (!patcherMethodDictionary.TryGetValue(Path.GetFileName(assemblyFilenames[assembly]), out IList<AssemblyPatcherDelegate> patcherMethods))
+                        continue;
 
-                Patch(assembly, patcherMethods);
+                    Patch(assembly, patcherMethods);
+                }
             }
         }
 
         public static void Patch(AssemblyDefinition assembly, IEnumerable<AssemblyPatcherDelegate> patcherMethods)
         {
-#if CECIL_10
-            using (assembly)
-#endif
             using (MemoryStream assemblyStream = new MemoryStream())
             {
                 foreach (AssemblyPatcherDelegate method in patcherMethods)