LavaGang / MelonLoader

The World's First Universal Mod Loader for Unity Games compatible with both Il2Cpp and Mono
https://discord.gg/2Wn3N2P
Apache License 2.0
2.22k stars 458 forks source link

[Bug]: Possible incompatibility of Il2CppInterop with generated assemblies #651

Closed Seva167 closed 4 days ago

Seva167 commented 1 month ago

All of the following criteria must be met

All of the following are optional to answer

Describe the issue.

Latest.log This issue occured when i tried to register class in Il2Cpp that inherits from ingame Il2Cpp type. Ingame type had virtual method with arguments that have ingame Il2Cpp type. It looks like all ingame types are in "Il2Cpp" namespace when referencing generated assembly: Il2Cpp.CubeConnector, Assembly-CSharp, while Il2CppInterop ClassInjector tries to find type name and ignores that: CubeConnector, Assembly-CSharp

I fixed it with this patch:

[HarmonyPatch(typeof(ClassInjector), "GetIl2CppTypeFullName")]
internal static class ClassInjectorPatch
{
    public static void Postfix(ref string __result)
    {
        if (__result.Contains("Assembly-CSharp"))
        {
            __result = "Il2Cpp." + __result;
            MelonLogger.Msg(__result);
        }
    }
}

Did you attach your log file?

Yes, I attached my log file to the text box above.

HerpDerpinstine commented 4 days ago

Should be fixed in the upcoming v0.6.5 update