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()) {