Skip to content

fix: Unity 6.5 projects compile without metadata type conflicts - #1377

Merged
hatayama merged 1 commit into
mainfrom
fix/issue-1370
Jun 20, 2026
Merged

fix: Unity 6.5 projects compile without metadata type conflicts#1377
hatayama merged 1 commit into
mainfrom
fix/issue-1370

Conversation

@hatayama

@hatayama hatayama commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Fixes #1370

Summary

  • Unity 6.5 projects can compile Unity CLI Loop without duplicate metadata type errors.
  • Older Unity versions keep using the bundled metadata validation dependencies.

User Impact

  • Before this change, Unity CLI Loop 2.1.8 and 2.1.9 failed to compile on Unity 6000.5 with CS0433 errors from metadata validation code.
  • Unity 6000.5 now uses Unity-provided metadata assemblies while earlier supported Editors keep the bundled dependencies.

Changes

  • Exclude bundled metadata validation dependency plugins from Unity 6000.5 and newer with Unity define constraints.
  • Keep the explicit-reference importer setting that prevents accidental implicit references.
  • Add package metadata coverage for the Unity 6000.5 exclusion.

Verification

  • uloop compile --force-recompile true --wait-for-domain-reload true
  • npm --prefix Packages/src/Cli~ run test:cli -- --runTestsByPath src/__tests__/package-metadata.test.ts
  • npm --prefix Packages/src/Cli~ run lint
  • npm --prefix Packages/src/Cli~ run build
  • codex review --commit HEAD

Review in cubic

Summary

This PR fixes compilation failures in Unity CLI Loop when building with Unity 6.5 (version 6000.5 and newer) that were present in versions 2.1.8 and 2.1.9.

Problem

The bundled metadata validation dependency packages caused CS0433 errors (duplicate metadata type conflicts) when compiling with Unity 6000.5 and newer, which now includes its own System.Reflection.Metadata reference during editor compilation.

Solution

The fix excludes bundled metadata validation dependencies from Unity 6000.5+ through Unity define constraints, while maintaining explicit-reference importer settings for older Unity versions to prevent accidental implicit references. Package metadata coverage is added to document and enforce the exclusion.

Changes

Packages/src/Cli~/src/tests/package-metadata.test.ts

  • Added constant METADATA_VALIDATION_DEPENDENCY_DEFINE_CONSTRAINT = '!UNITY_6000_5_OR_NEWER'
  • Introduced new test case: "excludes bundled metadata validation dependencies from Unity 6000.5 and newer"
  • Test validates that each metadata validation dependency .meta file (System.Collections.Immutable, System.Reflection.Metadata, and System.Runtime.CompilerServices.Unsafe) contains the !UNITY_6000_5_OR_NEWER define constraint

The test verifies the define constraint is properly configured in the three bundled dependency .meta files to ensure they are excluded when compiling with Unity 6000.5 and newer versions.

Verification

The fix has been verified through:

  • Compilation with force-recompile and domain-reload options
  • Package metadata tests
  • Linting and building
  • Code review

Unity 6000.5 now references System.Reflection.Metadata during editor compilation,
so the package must not import the bundled metadata validation dependencies there.
Keep explicit-reference protection for older Unity versions and add metadata coverage.
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

A new constant METADATA_VALIDATION_DEPENDENCY_DEFINE_CONSTRAINT (!UNITY_6000_5_OR_NEWER) is added to the package metadata test file. A new Jest test iterates over METADATA_VALIDATION_DEPENDENCY_META_PATHS and asserts each .meta file contains an exclusion entry referencing that constraint.

Changes

Metadata validation dependency define constraint test

Layer / File(s) Summary
Define constraint constant and .meta exclusion test
Packages/src/Cli~/src/__tests__/package-metadata.test.ts
Adds METADATA_VALIDATION_DEPENDENCY_DEFINE_CONSTRAINT = '!UNITY_6000_5_OR_NEWER' and a test that loads each metadata validation dependency .meta file and verifies it contains the string - '<!UNITY_6000_5_OR_NEWER>'.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related issues

Possibly related PRs

  • hatayama/unity-cli-loop#1288: Both PRs modify the same test file (package-metadata.test.ts) to validate bundled metadata validation dependency .meta file contents using METADATA_VALIDATION_DEPENDENCY_META_PATHS, with the current PR extending those checks to cover the !UNITY_6000_5_OR_NEWER define constraint.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title mentions 'Unity 6.5 projects compile without metadata type conflicts,' which aligns with the PR objective of fixing compilation failures in Unity 6.5. However, the actual changeset only adds a test case and a constant for Unity 6000.5 exclusion; it doesn't show the complete implementation of the fix (the actual meta file modifications are in ignored files). The title partially reflects the main change but oversimplifies the scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-1370

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Re-trigger cubic

@hatayama
hatayama merged commit 4a33119 into main Jun 20, 2026
5 checks passed
@hatayama
hatayama deleted the fix/issue-1370 branch June 20, 2026 11:07
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.

Unity 6000.5: CS0433 metadata type conflicts with 2.1.8 and 2.1.9

1 participant