Skip to content

Fix stale Cpp2IL output cleanup - #1193

Merged
HerpDerpinstine merged 1 commit into
LavaGang:alpha-developmentfrom
ifBars:agent/clear-stale-cpp2il-output
Aug 13, 2026
Merged

Fix stale Cpp2IL output cleanup#1193
HerpDerpinstine merged 1 commit into
LavaGang:alpha-developmentfrom
ifBars:agent/clear-stale-cpp2il-output

Conversation

@ifBars

@ifBars ifBars commented Aug 5, 2026

Copy link
Copy Markdown

Summary

  • let Cpp2IL inherit the standard executable-package cleanup
  • remove stale cpp2il_out assemblies before each generation and after completion
  • ensure Il2CppInterop only consumes assemblies emitted for the current game build

Root cause

Cpp2IL.Cleanup() was overridden with an empty implementation. Cpp2IL writes into an existing directory without removing assemblies that disappeared between game versions, and Il2CppInterop reads every DLL in that directory.

The inherited ExecutablePackage.Cleanup() is already scoped to OutputFolder, so it removes cpp2il_out without removing the downloaded Cpp2IL executable.

Closes #1192.

Cross-project source trace

  • Cpp2IL 2022.1.0-pre-release.21 creates the output directory if needed and writes current assemblies, but does not remove assemblies it no longer emits.
  • In the reproduced mixed directory, stale Cinemachine.dll from 0.4.5f2 references UnityEngine.Camera.GateFitMode; the current 0.4.6f11 CoreModule no longer defines that enum, and a clean current Cpp2IL run does not emit Cinemachine.dll.
  • MelonLoader's pinned Il2CppInterop version resolves and immediately consumes each field type in Pass 11, explaining the observed null failure on that cross-version graph.
  • BepInEx/Il2CppInterop#275 independently reports the same game, Unity version, stack, and exact Cinemachine.LensSettings.GateFit -> UnityEngine.Camera.GateFitMode reference. Its defensive downstream handling is complementary; this PR prevents MelonLoader from constructing the invalid mixed input set.

The full type-level evidence and controls are recorded in #1192.

Verification

  • dotnet build MelonLoader.sln --no-restore -c Release -p:Platform=x64 -p:Version=0.7.3-stale-output-fix
  • dotnet build MelonLoader.sln --no-restore -c Release -p:Platform=x86 -p:Version=0.7.3-stale-output-fix
  • reproduced the failure with official MelonLoader 0.7.3 by generating against Schedule I 0.4.5f2, then updating the same disposable install to 0.4.6f11
  • confirmed the old run left 123 Cpp2IL DLLs while a clean current run emits 111; 12 removed game assemblies remained stale and caused Pass11ComputeTypeSpecifics to throw
  • replaced only Il2CppAssemblyGenerator.dll with the source-built version while preserving all 123 stale inputs
  • confirmed 0.4.6f11 regenerated successfully, removed cpp2il_out, retained none of the 12 old-only assemblies, and reached Loading Mods with zero generation errors

@HerpDerpinstine
HerpDerpinstine merged commit 77d6c4d into LavaGang:alpha-development Aug 13, 2026
@ifBars
ifBars deleted the agent/clear-stale-cpp2il-output branch August 13, 2026 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants