fix: Avoid dependency conflicts from bundled metadata DLLs - #1288
Conversation
Keep bundled CodeAnalysis dependencies explicit-only so consuming Unity projects do not receive uLoop's System.Runtime.CompilerServices.Unsafe.dll through implicit plugin references.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (5)
📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds test-only constants for Unity dependency ChangesPackage metadata tests
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Move the bundled System.* metadata validation assemblies under the owning editor assembly with uLoop-specific file names, so consumer asmdefs that reference System.Runtime.CompilerServices.Unsafe.dll resolve their own package dependency instead of uLoop's private copy.
Rename the bundled metadata validation dependency assembly identities to match their uLoop-specific DLL names, so Unity and Burst do not resolve them as System.* assemblies while consumer packages keep using their own dependencies.
Delete the empty package Plugins folder metadata left after moving the metadata validation DLLs, and add package metadata coverage so clean Unity imports do not recreate an empty folder or warn about the orphan.
The identity rewrite removed the strong-name signature and public key
from the bundled metadata validation dependencies but left the
StrongNameSigned bit set in the COR20 header. CoreCLR rejects such
images with BadImageFormatException ("Bad IL format"), so the DLLs
would fail to load outside Mono-based editors.
- Clear the StrongNameSigned CorFlag in all three dependency DLLs
- Add a package metadata test that parses the COR20 header and guards
against the flag regressing
Summary
User Impact
Changes
Verification
Closes #1284
Summary
This PR adds comprehensive test coverage for the bundled metadata validation DLLs under the editor-only metadata validation package, ensuring they remain private and explicitly referenced only.
Changes Made
File:
Packages/src/Cli~/src/__tests__/package-metadata.test.ts(+103 lines)New Test Infrastructure
loadUnityPackageText(relativePath)andloadUnityPackageBytes(relativePath)to read checked-in Unity asset metadata and DLL binaries from stable repo-relative pathsMETADATA_VALIDATION_DEPENDENCY_META_PATHS: Three.dll.metafile pathsMETADATA_VALIDATION_PRIVATE_ASSEMBLIES: Assembly configurations with name, path, and reference mappingsNew Test Cases
Explicit Reference Flag Verification (
keeps bundled metadata validation dependencies out of implicit project references): Verifies each metadata validation dependency.metafile containsisExplicitlyReferenced: 1, preventing implicit project referencesPrivate Assembly Identity Verification (
uses private assembly identities for metadata validation dependencies): Confirms each dependency DLL contains the correct private assembly name (withuLoopMCPprefix) and all declared assembly references within its binaryStrong-Name Signature Verification (
does not claim strong-name signing on unsigned metadata validation dependencies): Parses PE/CLI headers to verify theStrongNameSignedflag is cleared on all three dependency DLLs, preventingBadImageFormatExceptionon CoreCLR when strong-name signatures were stripped during identity rewritingOrphaned Metadata Cleanup (
does not keep orphaned plugin folder metadata): Confirms thePlugins.metafile was removed after moving DLLsTechnical Details
readCorHeaderFlags) to inspect theCOR20header and verify theCOMIMAGE_FLAGS_STRONGNAMESIGNEDflag stateuLoopMCP.System.Runtime.CompilerServices.Unsafe.dll(no references)uLoopMCP.System.Collections.Immutable.dll(references Unsafe)uLoopMCP.System.Reflection.Metadata.dll(references both Unsafe and Collections.Immutable)Impact
#1284where consuming projects (e.g., those using MemoryPack) would encounter implicit dependency conflicts with unity-cli-loop's bundled metadata validation DLLs