From bea51061e0ec78c3b76569b62c1e3c87661121a5 Mon Sep 17 00:00:00 2001 From: js6pak Date: Wed, 19 Oct 2022 18:04:25 +0200 Subject: [PATCH] Add a config option to disable xref and disable it by default on x32 --- .../Unity/BepInEx.Unity.IL2CPP/Il2CppInteropManager.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Runtimes/Unity/BepInEx.Unity.IL2CPP/Il2CppInteropManager.cs b/Runtimes/Unity/BepInEx.Unity.IL2CPP/Il2CppInteropManager.cs index d88e7d9..4c900f4 100644 --- a/Runtimes/Unity/BepInEx.Unity.IL2CPP/Il2CppInteropManager.cs +++ b/Runtimes/Unity/BepInEx.Unity.IL2CPP/Il2CppInteropManager.cs @@ -58,6 +58,11 @@ internal static class Il2CppInteropManager .AppendLine("resulting in names that persist after game updates.") .ToString()); + private static readonly ConfigEntry ScanMethodRefs = ConfigFile.CoreConfig.Bind( + "IL2CPP", "ScanMethodRefs", + Environment.Is64BitProcess, + "If enabled, Il2CppInterop will use xref to find dead methods and generate CallerCount attributes."); + private static readonly ConfigEntry DumpDummyAssemblies = ConfigFile.CoreConfig.Bind( "IL2CPP", "DumpDummyAssemblies", false, @@ -287,7 +292,7 @@ internal static class Il2CppInteropManager { var opts = new GeneratorOptions { - GameAssemblyPath = GameAssemblyPath, + GameAssemblyPath = ScanMethodRefs.Value ? GameAssemblyPath : null, Source = sourceAssemblies, OutputDir = IL2CPPInteropAssemblyPath, UnityBaseLibsDir = Directory.Exists(UnityBaseLibsDirectory) ? UnityBaseLibsDirectory : null,