Add closed hierarchies for C# 15, preview 5#54128
Draft
BillWagner wants to merge 10 commits into
Draft
Conversation
Publish the feature spec for closed hierarchies.
Add a new reference article for `closed`. Update snippets and the associated TOC.
The `closed` hierarchy impacts pattern exhaustiveness and subsumption. Add a section to discuss that in the patterns reference article.
Add the `closed` contextual keyword to the What's new in C# 15 article.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds C# 15 Preview 5 documentation for the new closed modifier (closed class hierarchies), including a new language reference article, updated pattern matching guidance on exhaustiveness/subsumption, a “What’s new” entry, and publication wiring for the feature specification.
Changes:
- Add
closedmodifier reference content and link it into the keyword index and TOC. - Extend pattern matching docs with a new “Closed hierarchy patterns” section and new snippets.
- Publish the
closed-hierarchiesproposal content via spec TOC anddocfx.jsonconfiguration.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/csharp/whats-new/csharp-15.md | Adds “Closed hierarchies” to the C# 15 preview feature list with examples and links. |
| docs/csharp/specification/toc.yml | Adds “Closed hierarchies” entry to the specification TOC pointing at the proposal. |
| docs/csharp/language-reference/toc.yml | Adds closed keyword entry to the language reference TOC. |
| docs/csharp/language-reference/operators/snippets/patterns/patterns.csproj | Updates snippet project TFM to net11.0 (but needs LangVersion for preview syntax). |
| docs/csharp/language-reference/operators/snippets/patterns/ClosedHierarchyPatterns.cs | Introduces new closed-hierarchy pattern matching snippets and narrative comments. |
| docs/csharp/language-reference/operators/patterns.md | Adds “Closed hierarchy patterns” section explaining exhaustiveness, accessibility, and subsumption. |
| docs/csharp/language-reference/keywords/snippets/shared/Closed.cs | Adds shared closed keyword snippets for the reference article. |
| docs/csharp/language-reference/keywords/snippets/keywords.csproj | Updates snippet project TFM to net11.0-windows (but needs LangVersion for preview syntax). |
| docs/csharp/language-reference/keywords/index.md | Adds closed to the contextual keywords list. |
| docs/csharp/language-reference/keywords/closed.md | Adds the new closed modifier reference article and links to related guidance/spec. |
| docfx.json | Wires in the new proposal file for build/metadata/title/description. |
Comments suppressed due to low confidence (1)
docs/csharp/language-reference/keywords/snippets/keywords.csproj:12
- The keywords snippet project now targets net11.0-windows and includes C# 15 preview syntax (the
closedmodifier), but the project doesn't setLangVersiontopreview. If the build defaults to a stable language version, the newclosedsnippets won't compile.
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<OutputType>WinExe</OutputType>
<TargetFramework>net11.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<StartupObject>Keywords.Program</StartupObject>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
<UseWPF>true</UseWPF>
</PropertyGroup>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Add note on exhaustiveness checks for type parameters.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #54013
closedcontextual keyword.closedhierarchies.Internal previews
isandswitchexpressions, and operatorsand,or, andnotin patterns