Allow plugins to find non-harmony types in other plugins
All checks were successful
Build / Compute Version (push) Successful in 4s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 1m50s
Build / Build Nuget package (NuGet) (push) Successful in 1m50s
Build / Build Nuget package (CringePlugins) (push) Successful in 2m17s
Build / Build Nuget package (SharedCringe) (push) Successful in 2m38s
Build / Build Launcher (push) Successful in 3m16s

This commit is contained in:
2024-11-03 18:34:34 -05:00
parent b3ef089a70
commit 02584dfcfb
2 changed files with 55 additions and 2 deletions

View File

@@ -78,6 +78,19 @@ public static class IntrospectionPatches
return false;
}
[HarmonyPrefix, HarmonyPatch(typeof(AccessTools), nameof(AccessTools.TypeByName))]
private static bool TypeByNameHarmonyPrefix(ref Type __result, string name)
{
if (!PluginAssemblyLoadContext.TypeToAssembly.TryGetValue(name, out var assembly))
return true;
var module = assembly.GetMainModule();
__result = module.GetType(name, true, false)!;
return false;
}
[HarmonyPrefix, HarmonyPatch(typeof(AccessTools), nameof(AccessTools.AllAssemblies))]
private static bool AllAssembliesHarmonyPrefix(ref IEnumerable<Assembly> __result)
{