From ede04392357dab53c4c78b658e9c2fe0c9b9540a Mon Sep 17 00:00:00 2001 From: slxdy Date: Mon, 25 Aug 2025 23:06:36 +0200 Subject: [PATCH] Fix Pass 90 imports TargetFrameworkAttribute after corlib refs fixup Pass 90 would import the TargetFrameworkAttribute after the corlib refs fixup, which would result in a single remaining direct System.Private.CorLib reference. --- .../Passes/Pass90WriteToDisk.cs | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Il2CppInterop.Generator/Passes/Pass90WriteToDisk.cs b/Il2CppInterop.Generator/Passes/Pass90WriteToDisk.cs index d86cb200..8bb6ea15 100644 --- a/Il2CppInterop.Generator/Passes/Pass90WriteToDisk.cs +++ b/Il2CppInterop.Generator/Passes/Pass90WriteToDisk.cs @@ -18,18 +18,6 @@ public static void DoPass(RewriteGlobalContext context, GeneratorOptions options { var module = asmContext.NewAssembly.ManifestModule!; - // Rewrite corlib references. - foreach (var reference in module.AssemblyReferences) - { - // System.Private.CoreLib needs rewriting because references can get created during the rewrite process. - // mscorlib and netstandard are included for completeness. - if (reference.Name?.Value is "System.Private.CoreLib" or "mscorlib" or "netstandard") - { - CorlibReferences.RewriteCorlibReference(reference); - continue; - } - } - // Add TargetFrameworkAttribute to the assembly. { var importedConstructor = (ICustomAttributeType)module.DefaultImporter.ImportMethod(targetAttributeConstructor); @@ -49,6 +37,18 @@ public static void DoPass(RewriteGlobalContext context, GeneratorOptions options asmContext.NewAssembly.CustomAttributes.Add(targetFrameworkAttribute); } + // Rewrite corlib references. + foreach (var reference in module.AssemblyReferences) + { + // System.Private.CoreLib needs rewriting because references can get created during the rewrite process. + // mscorlib and netstandard are included for completeness. + if (reference.Name?.Value is "System.Private.CoreLib" or "mscorlib" or "netstandard") + { + CorlibReferences.RewriteCorlibReference(reference); + continue; + } + } + // Optimize macros in all methods and assign tokens. foreach (var type in module.GetAllTypes()) {