Skip to content

Fix CS1705 on Unity 6000.5: downgrade bundled Roslyn 4.14 → 4.12#56

Merged
Niaobu merged 1 commit into
mainfrom
fix/roslyn-4.12-cs1705
Jun 22, 2026
Merged

Fix CS1705 on Unity 6000.5: downgrade bundled Roslyn 4.14 → 4.12#56
Niaobu merged 1 commit into
mainfrom
fix/roslyn-4.12-cs1705

Conversation

@Niaobu

@Niaobu Niaobu commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Problem

On Unity 6000.5 (.NET 8), the bundled Roslyn 4.14 fails to compile the UnityCtl.dll editor assembly:

CS1705: Assembly 'Microsoft.CodeAnalysis(.CSharp)' v4.14 uses
        System.Collections.Immutable 9.0.0 which has a higher version
        than referenced assembly System.Collections.Immutable 8.0.0

6000.5 ships System.Collections.Immutable 8.0 in its netstandard2.1 targeting pack, which shadows the bundled 9.0 that Roslyn 4.14 requires. Reported by @bradar93 in #54.

Fix

Downgrade the bundled Editor/Plugins/Roslyn DLLs to the Roslyn 4.12 set, which targets Immutable 8.0 (matching what 6000.5 provides):

  • Microsoft.CodeAnalysis / Microsoft.CodeAnalysis.CSharp 4.14 → 4.12
  • System.Collections.Immutable / System.Reflection.Metadata 9.0 → 8.0
  • System.Runtime.CompilerServices.Unsafe 6.0 and System.Text.Encoding.CodePages 7.0 unchanged

No capability lost

Roslyn 4.12, 4.13, and 4.14 all max out at C# 13 (.NET 9 / VS 17.x). C# 14 requires Roslyn 5.0 / .NET 10, so the downgrade unlocks nothing we would otherwise have. script eval compiles C# 13 and earlier — unaffected.

Testing

Verified on a live editor for both versions:

  • 6000.5.0f1: CS1705 gone, UnityCtl.dll compiles, plugin connects, script eval "return 2+2" → 4, and snapshot --id 568105584918841322 (a real 64-bit EntityId) round-trips.
  • 6000.3.15f1: no regression — compiles clean, script eval and snapshot --id round-trip.

@
Fix CS1705 on Unity 6000.5: downgrade bundled Roslyn 4.14 -> 4.12

Unity 6000.5 (.NET 8) ships System.Collections.Immutable 8.0 in its
netstandard2.1 targeting pack, which shadows the bundled Immutable 9.0
that Roslyn 4.14 requires, so UnityCtl.dll fails to compile (CS1705).
Roslyn 4.12 targets Immutable 8.0, matching what 6000.5 provides.

Swaps the bundled Plugins/Roslyn DLLs:
- Microsoft.CodeAnalysis(.CSharp) 4.14 -> 4.12
- System.Collections.Immutable / System.Reflection.Metadata 9.0 -> 8.0
(Unsafe 6.0 and Text.Encoding.CodePages 7.0 unchanged.)

Same C# 13 language support (C# 14 needs Roslyn 5.0 / .NET 10), so no
script-eval capability is lost. Verified script eval + snapshot --id
round-trips clean on both 6000.3.15f1 and 6000.5.0f1.

Reported by @bradar93 in #54.
@
@Niaobu Niaobu merged commit f8021e2 into main Jun 22, 2026
1 check passed
@Niaobu Niaobu deleted the fix/roslyn-4.12-cs1705 branch June 22, 2026 10:20
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