Skip to content

fix(magic-unity): select workaround signature assemblies from player compilation references#22

Closed
skydread1 wants to merge 2 commits into
mainfrom
fix/magic-unity-player-reference-selection
Closed

fix(magic-unity): select workaround signature assemblies from player compilation references#22
skydread1 wants to merge 2 commits into
mainfrom
fix/magic-unity-player-reference-selection

Conversation

@skydread1

@skydread1 skydread1 commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Closes #23.

Fix

Collect an assembly only if it is in the player compilation reference set (CompilationPipeline.GetAssemblies(AssembliesType.PlayerWithoutTestAssemblies) plus allReferences). Editor-only assemblies are excluded structurally on every platform, with no name list to maintain. Only assembly selection changes; the generated workaround code is untouched.

  • Keep and skip decisions are logged, so selection changes are auditable in build logs.
  • A degenerate reference set (missing core libraries or UnityEngine modules) fails the build instead of silently emitting no workarounds.

Validation

  • Smoke project, full IL2CPP build and run on Mac: 41/41 checks passed.
  • Selection on Mac keeps mscorlib, System.*, UnityEngine modules and user assemblies; drops only Mono.Security and System.Configuration (editor-only on Mac).
  • csc.rsp references verified to stay in the pool (reproduced with -r:System.Web.dll).
  • Windows is not yet exercised; the keep/skip log lines are the review surface for that. The new selected set is strictly a subset of the old closure, so dropped lines fully describe the behavior change.

@skydread1 skydread1 added the comp:magic-unity Unity UPM package and IL2CPP workarounds label Jun 5, 2026
…compilation references (#23)

GenerateGenericWorkaroundMethods collected dispatch target signatures by
walking the type reference closure from Assembly-CSharp against the
editor's full desktop BCL, trimmed only by a Unity prefix check. On
Windows that closure reaches editor-only assemblies like Mono.WebBrowser,
and signatures referencing them break the IL2CPP build.

Replace the prefix heuristic with an allowlist derived from
CompilationPipeline player compilation references: an assembly's methods
can only be dynamic dispatch targets in the player if player scripts
compile against it. Editor-only assemblies are excluded structurally on
any platform, with no name list to maintain. References added via rsp
files are part of the player compilation reference set, so they stay in
the signature pool. Init logs the reference set and each skip logs its
reason so selection changes are auditable in build logs, and a guard
fails the build if the reference set ever looks degenerate, instead of
silently generating no workarounds.

Verified on the smoke project: IL2CPP build and run, 41/41 checks passed.
@skydread1 skydread1 force-pushed the fix/magic-unity-player-reference-selection branch from 54b7308 to 7cc6a89 Compare June 5, 2026 03:38
@skydread1 skydread1 marked this pull request as draft June 5, 2026 03:40
@skydread1 skydread1 closed this Jun 5, 2026
@skydread1 skydread1 deleted the fix/magic-unity-player-reference-selection branch June 8, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:magic-unity Unity UPM package and IL2CPP workarounds

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant