Skip to content

fix: reference System.Security.Cryptography.Primitives when building the Roslyn worker - #2070

Merged
hatayama merged 1 commit into
v3-betafrom
fix/roslyn-worker-crypto-primitives-ref
Jul 29, 2026
Merged

fix: reference System.Security.Cryptography.Primitives when building the Roslyn worker#2070
hatayama merged 1 commit into
v3-betafrom
fix/roslyn-worker-crypto-primitives-ref

Conversation

@hatayama

@hatayama hatayama commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • Shared Roslyn worker rebuilds no longer fail with CS0012 on HashAlgorithmName when the Unity NetCoreRuntime ships System.Security.Cryptography.Primitives.dll.
  • That rebuild failure previously logged as an Unhandled error and failed WatchExpressionCompilerTests during EditMode runs after other tests shut down the shared worker.
  • Adds a regression test that asserts the worker reference set includes Primitives when the assembly exists on disk.

Root cause

Rebuilding the shared worker compiles RoslynCompilerWorker.cs against Microsoft.CodeAnalysis. The Emit API surface requires HashAlgorithmName from System.Security.Cryptography.Primitives, but BuildWorkerReferenceSet did not reference that assembly. After ExternalCompilerPathResolverTests deleted the worker DLL / cleared health-monitor once-flags, Watch expression compilation rebuilt the worker, hit CS0012, and ReportSharedWorkerFailure emitted Debug.LogError.

Test plan

  • uloop compile → 0 errors / 0 warnings
  • Deleted $TMPDIR/UnityCliLoopCompilation/RoslynWorker-<pid>/, then EditMode regex ExternalCompilerPathResolverTests|WatchExpressionCompilerTests → 18/18 passed (pre-fix: 1 failure on ValidExpression)
  • Worker DLL regenerated; rsp includes System.Security.Cryptography.Primitives.dll
  • No new CS0012 in today's VibeLogger after the verification run (only expected synthetic worker_build_failed from path-resolver fallback smoke)
  • Solo exact filter for BuildWorkerReferenceSet_WhenPrimitivesAssemblyExists_ShouldIncludePrimitivesReference → passed

Review in cubic

…oslyn worker

Without this assembly, rebuilding the shared worker fails with CS0012 on
HashAlgorithmName from the CodeAnalysis Emit API, which surfaces as an
Unhandled log and fails WatchExpressionCompilerTests in full EditMode runs.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3dd3a3f9-72ae-4234-a5e3-f7b736c19682

📥 Commits

Reviewing files that changed from the base of the PR and between 4f656ea and 0b47c7e.

📒 Files selected for processing (2)
  • Assets/Tests/Editor/DynamicCodeToolTests/SharedRoslynCompilerWorkerHostTests.cs
  • Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCompilation/SharedRoslynCompilerWorkerAssemblyBuilder.cs

📝 Walkthrough

Walkthrough

The worker reference builder now conditionally includes System.Security.Cryptography.Primitives.dll when available. Its reference-building method is internally accessible, and a new editor test validates the generated reference set.

Changes

Cryptography reference support

Layer / File(s) Summary
Reference set update and validation
Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCompilation/SharedRoslynCompilerWorkerAssemblyBuilder.cs, Assets/Tests/Editor/DynamicCodeToolTests/SharedRoslynCompilerWorkerHostTests.cs
BuildWorkerReferenceSet is now internal and conditionally adds System.Security.Cryptography.Primitives.dll; the editor test checks that the path is included when the assembly exists and ignores the test otherwise.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding the Primitives reference when building the Roslyn worker.
Description check ✅ Passed The description is directly aligned with the code changes and explains the bug fix, root cause, and regression test.
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.
✨ 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/roslyn-worker-crypto-primitives-ref

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.

@hatayama
hatayama merged commit 8bb1f28 into v3-beta Jul 29, 2026
14 checks passed
@hatayama
hatayama deleted the fix/roslyn-worker-crypto-primitives-ref branch July 29, 2026 13:39
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.

1 participant