Repository navigation
fix: reference the Roslyn assemblies from MCPForUnity.Editor.asmdef - #1359
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe editor assembly definition now references the Roslyn DLLs installed by ChangesRoslyn assembly reference validation
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The change enables the optional Roslyn integration to compile in UPM installs while leaving projects without Roslyn unaffected, and adds coverage to prevent reference drift. No actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Linked Issues checkExplanation The PR satisfies issue Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. (3 skipped: 3 unsupported.)
✨ Finishing Touches🧪 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 |
MCPForUnity.Editor sets overrideReferences, so it only sees precompiled assemblies it names explicitly, and precompiledReferences listed only Newtonsoft.Json.dll. RoslynInstaller writes its DLLs into the consuming project's Assets/Plugins/Roslyn, outside the package, so defining USE_ROSLYN left ManageScript.cs unable to resolve its Microsoft.CodeAnalysis using directives and broke the build. Embedded installs happened to work; UPM installs could not. Adds the five DLL names RoslynInstaller installs. Unity ignores a precompiledReferences entry whose assembly is absent, so projects without Roslyn are unaffected — verified by the full EditMode suite compiling and passing with none of these DLLs present. The new test reads the DLL list off RoslynInstaller by reflection rather than duplicating it, so the two cannot drift apart. Closes CoplayDev#1295
c47b5f2 to
a402781
Compare
…upstream CoplayDev#1359) (cherry picked from upstream merge 9834f8d)
Description
MCPForUnity.Editor.asmdefsets"overrideReferences": true, which means the assembly only sees precompiled assemblies it names explicitly — andprecompiledReferenceslisted justNewtonsoft.Json.dll.RoslynInstallerwrites its DLLs toApplication.dataPath/Plugins/Roslyn, i.e. the consuming project'sAssets/Plugins/Roslyn, which is outside the package. So the moment a user follows the Roslyn guide and definesUSE_ROSLYN, theusing Microsoft.CodeAnalysis;directives inManageScript.cscannot resolve and the build breaks. Embedded installs happened to work; UPM installs could not.Worth noting
ExecuteCode.csalready dodges this by reaching Roslyn throughType.GetType(...)reflection instead of compile-timeusingdirectives —ManageScript.cswas simply never given the same treatment.Type of Change
Changes Made
MCPForUnity/Editor/MCPForUnity.Editor.asmdef: added the five DLL namesRoslynInstallerinstalls toprecompiledReferences.RoslynAsmdefReferenceTests: asserts the asmdef references every DLL the installer writes. It reads that list offRoslynInstaller.NuGetEntriesby reflection rather than duplicating it, so if someone adds or renames a Roslyn dependency the test fails instead of silently drifting.I wrote the test first and confirmed it fails on
betabefore the asmdef change, naming all five missing assemblies:Compatibility / Package Source
file:(local clone, branchfix/roslyn-upm-asmdef-referencesoffbeta)Packages/packages-lock.json: n/a (file reference)Testing/Screenshots/Recordings
Full EditMode suite on 2022.3.62f1: 1120 passed, 0 failed (66 pre-existing ignores), with zero compile errors.
That last point is the one I most wanted to verify rather than assume:
TestProjects/UnityMCPTestshas none of these Roslyn DLLs present, and the project still compiles cleanly with them listed. So Unity does ignore aprecompiledReferencesentry whose assembly is absent, and this change is a no-op for the majority of projects that never install Roslyn.Documentation Updates
website/docs/guides/roslyn.mdstill describes the correct user-facing flow, so no doc change was needed.Related Issues
Closes #1295
Additional Notes
What I could not verify locally is the positive case end to end: a UPM install with the DLLs actually present in
Assets/Plugins/RoslynandUSE_ROSLYNdefined, compiling successfully. I verified the mechanism (absent entries are ignored; the names now match what the installer writes) but if one of you has a project already set up that way, a confirmation would be worth having before merge.The alternative fix would be converting
ManageScript.cs's six#if USE_ROSLYNblocks to reflection, mirroringExecuteCode.cs. That removes the asmdef question entirely but is a much larger and riskier change, so I went with the small one — happy to take the other route if you'd prefer it.Summary by CodeRabbit
Bug Fixes
Tests