Document labeled break and continue (C# 15)#54999
Draft
BillWagner wants to merge 1 commit into
Draft
Conversation
Add documentation for the C# 15 labeled `break` and `continue` feature: - Language reference: extend the `break` and `continue` sections in jump-statements.md, with new snippet examples (LabeledBreak, LabeledContinue). - What's new in C# 15: add a "Labeled break and continue" section. - Publish the feature speclet via the specification TOC and docfx.json (build include, title, and description metadata). The feature bits haven't shipped yet, so snippet output is reasoned from the speclet and will be verified against early bits. Fixes dotnet#54653 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: a542e9e6-723c-47d8-95e0-f4c371174bd8
Contributor
There was a problem hiding this comment.
Pull request overview
Documents the C# 15 labeled break and continue feature across the language reference, the C# 15 “What’s new” article, and the published feature specification (speclet).
Changes:
- Adds a new “Labeled
breakandcontinue” section to the C# 15 “What’s new” page. - Extends the jump statements reference to explain labeled targets for
breakandcontinue, and adds new snippet examples. - Publishes the speclet by wiring it into the C# specification TOC and
docfx.jsonproposal metadata.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/csharp/whats-new/csharp-15.md | Adds a new section and TOC entry describing labeled break/continue. |
| docs/csharp/specification/toc.yml | Adds the proposal under Feature specifications → Statements. |
| docs/csharp/language-reference/statements/snippets/jump-statements/ContinueStatement.cs | Adds a labeled continue snippet example. |
| docs/csharp/language-reference/statements/snippets/jump-statements/BreakStatement.cs | Adds a labeled break snippet example. |
| docs/csharp/language-reference/statements/jump-statements.md | Updates break/continue documentation and references the new snippets. |
| docfx.json | Includes the new proposal in build inputs and adds title/description metadata. |
Comment on lines
+45
to
+55
| outer: for (int day = 0; day < dailyRoutes.Length; day++) | ||
| { | ||
| Console.WriteLine($"Day {day + 1}:"); | ||
|
|
||
| foreach (string route in dailyRoutes[day]) | ||
| { | ||
| if (route == "Bridge closed") | ||
| { | ||
| Console.WriteLine(" Bridge closed; move to the next day."); | ||
| continue outer; | ||
| } |
Comment on lines
+69
to
+79
| outer: for (int aisle = 0; aisle < stockChecks.GetLength(0); aisle++) | ||
| { | ||
| for (int bay = 0; bay < stockChecks.GetLength(1); bay++) | ||
| { | ||
| Console.WriteLine($"Checking aisle {aisle}, bay {bay}."); | ||
|
|
||
| if (stockChecks[aisle, bay] == "Blocked") | ||
| { | ||
| Console.WriteLine("Blocked bay found. Stop the inspection."); | ||
| break outer; | ||
| } |
Comment on lines
+142
to
+158
| ```csharp | ||
| outer: for (int row = 0; row < grid.Height; row++) | ||
| { | ||
| for (int column = 0; column < grid.Width; column++) | ||
| { | ||
| if (grid[row, column].IsBlocked) | ||
| { | ||
| continue outer; | ||
| } | ||
|
|
||
| if (grid[row, column].IsGoal) | ||
| { | ||
| break outer; | ||
| } | ||
| } | ||
| } | ||
| ``` |
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.
Summary
Documents the C# 15 (.NET 11) labeled
breakandcontinuefeature. Fixes #54653.Scope is limited to the C# reference, publishing the speclet, and the What's new in C# 15 article.
Changes
jump-statements.md): extended thebreakandcontinuesections to cover labeled targets, clarified thatcontinuetargets loops only (notswitch), and added the "only the immediately-nested statement is labeled" nuance. New snippet examplesLabeledBreakandLabeledContinuein the jump-statements snippet project.csharp-15.md): new bullet + "Labeledbreakandcontinue" section.specification/toc.yml(Feature specifications → Statements) and todocfx.json(build include, title, and description metadata), following the pattern from Addclosedhierarchies for C# 15, preview 5 #54128.Notes for reviewers
.csfiles use the speclet syntax and their// Output:blocks are reasoned by hand. These will be verified against early bits before the PR is marked ready.labeled-break-continue.md.Internal previews
break,continue,return, andgoto