Skip to content

Bump Roslyn to 5.9.0 to accept the C# 15 closed modifier - #93

Merged
Mpdreamz merged 1 commit into
mainfrom
fix/closed-syntax
Sep 22, 2026
Merged

Mpdreamz merged 1 commit into
mainfrom
fix/closed-syntax

Conversation

@Mpdreamz

Copy link
Copy Markdown
Contributor

Files using the C# 15 closed modifier on record class or class were reported as unparsable and left unformatted. Bumping Microsoft.CodeAnalysis.CSharp from 5.6.0 to 5.9.0 — now the head-of-published version on NuGet — fixes the parse failure.

Prompt summary: Fix the parse failure reported in #92: files using the closed modifier are silently skipped rather than formatted.

Why

Roslyn 5.6.0 does not recognise closed as a valid modifier in LanguageVersion.Preview. Any file with a closed record class or closed class declaration produces a CS1002: ; expected diagnostic, which causes CSharpSource.TryParse to refuse the file outright. Roslyn 5.9.0 adds the missing grammar production and parses these declarations cleanly.

What

Roslyn version pin

The Microsoft.CodeAnalysis.CSharp exact-version pin in Directory.Packages.props moves from [5.6.0] to [5.9.0]. The inline comment was also stale — it claimed 5.6.0 was head-of-published; 5.9.0 is the new head. The note explaining why the SDK-bundled compiler is not matched is unchanged.

Regression test

ParsingTests.Accepts_C15_closed_modifier locks in the fix using the minimal repro from the issue: a closed record class with a sealed subtype. The test would have caught 5.6.0 immediately.

Verify

dotnet run --project tests/Nullean.Curb.Tests/
# Accepts_C15_closed_modifier — new test, must pass

🤖 Generated with Claude Code

Roslyn 5.6.0 does not recognise `closed` as a valid modifier for `record class`
or `class` declarations. Files using it were reported as unparsable and left
unformatted. Roslyn 5.9.0, now the head-of-published version on NuGet, parses
them cleanly at `LanguageVersion.Preview`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Mpdreamz Mpdreamz added bug Something isn't working enhancement New feature or request and removed bug Something isn't working labels Sep 21, 2026
@Mpdreamz
Mpdreamz merged commit afb6093 into main Sep 22, 2026
3 checks passed
@Mpdreamz
Mpdreamz deleted the fix/closed-syntax branch September 22, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant