Repository navigation
fix: keep MCPForUnity.Runtime out of player builds - #1512
sssooonnnggg wants to merge 1 commit into
Conversation
MCPForUnity.Runtime only holds helpers for MCPForUnity.Editor, but with includePlatforms empty it was compiled into every player build, bringing its Newtonsoft converters along. Limit it to the Editor platform. Add an EditMode test that checks neither package assembly is in the player assembly set and that the Runtime assembly is still compiled for the Editor.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Description
MCPForUnity.Runtimecurrently hasincludePlatforms: [], so it is compiled into every player build of any project that installs the package. It only contains helpers forMCPForUnity.Editor(compat shims, screenshot helpers, Newtonsoft converters). Inside the package, only the Editor assembly and the EditMode tests reference it, and several of its files already wrap theirUnityEditorcalls in#if UNITY_EDITOR.Shipping it in players has costs and no benefit:
JsonConverters (Vector3Converter,UnityMathematicsConverter, ...) can be found at runtime by packages that scan loaded assemblies for converters and add them toJsonConvert.DefaultSettings. This is the same kind of problem as Public UnityEngine.Object JsonConverter can disrupt existing Newtonsoft.Json serialization #1138, which happened in the Editor.This PR limits the assembly to the Editor platform. In the Editor nothing changes:
MCPForUnity.Editorand the EditMode tests still reference it as before.Type of Change
Changes Made
MCPForUnity/Runtime/MCPForUnity.Runtime.asmdef:includePlatformsset to["Editor"].PackageAssemblyPlatformTests: usesCompilationPipeline.GetAssembliesto check thatMCPForUnity.RuntimeandMCPForUnity.Editorare not in the player assembly set, and thatMCPForUnity.Runtimeis still compiled for the Editor.Compatibility / Package Source
file:(TestProjects/UnityMCPTests, and an embedded copy in our own project)file:source)Testing/Screenshots/Recordings
cd Server && uv run pytest tests/ -v)Ran
-runTests -testPlatform EditMode -testFilter MCPForUnityTests.Editor.PackageAssemblyPlatformTests:includePlatforms: []):PackageAssembly_IsNotCompiledIntoPlayer("MCPForUnity.Runtime")fails. This confirms the test catches the regression.I did not run the full Unity 2021.3 / Unity 6 matrix locally.
Documentation Updates
tools/UPDATE_DOCS_PROMPT.md(recommended)Related Issues
Relates to #1138
Additional Notes
This only breaks a project if its own player code references
MCPForUnity.Runtime(the assembly isautoReferenced). That code would now compile in the Editor but fail in player builds. Since the package is Editor tooling, I don't expect anyone to rely on that, but it's worth mentioning in the release notes.Summary by CodeRabbit
Bug Fixes
Tests