Add C# 15 extension indexers to extension members tutorial - #54802
Merged
Conversation
Update the extension members tutorial to cover the C# 15 addition of extension indexers. Reframe the tutorial for C# 14 and C# 15, bump the sample to .NET 11 preview with LangVersion preview, and add an "Add extension indexers" section. The new section introduces a Path type that stores (dX, dY) offsets and adds an extension indexer whose getter computes the absolute Point at an index (from Point.Origin) and whose setter adjusts the offset at that index. Build and run verified on the .NET 11 preview SDK. Closes dotnet#54658 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7fb88c54-e7d1-47af-b8f2-d60b34e50426
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the existing C# extension members tutorial to also cover the C# 15 preview feature extension indexers, including a new runnable Path example that demonstrates indexed get/set behavior implemented in an extension block.
Changes:
- Updates the tutorial narrative and checklist to cover both C# 14 extension members and C# 15 extension indexers.
- Updates the sample project to target
net11.0and use<LangVersion>preview</LangVersion>. - Adds a new
Pathtype plus an extension indexer implementation and end-to-end demo output.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| docs/csharp/whats-new/tutorials/snippets/PointExtensions/PointExtensions.csproj | Targets net11.0 and enables preview language features needed for extension indexers. |
| docs/csharp/whats-new/tutorials/snippets/PointExtensions/Path.cs | Introduces the Path sample type that stores relative (dX, dY) offsets. |
| docs/csharp/whats-new/tutorials/snippets/PointExtensions/NewExtensionsMembers.cs | Adds a Path extension indexer and reorganizes Point extension blocks for type vs. instance members. |
| docs/csharp/whats-new/tutorials/snippets/PointExtensions/ExtensionMemberDemonstrations.cs | Adds a PathIndexer() demo and updates the scenario numbering accordingly. |
| docs/csharp/whats-new/tutorials/extension-members.md | Expands tutorial content to cover extension indexers, adds prerequisites/project-file step, and links to C# 15 and the speclet. |
Proofread the article, update the text description and edit for style.
BillWagner
marked this pull request as ready for review
July 15, 2026 16:01
Extend the PathIndexer snippet region to include the private ValidatePathIndex helper the accessors call, so readers see the complete code. Add a sentence noting the shared helper. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7fb88c54-e7d1-47af-b8f2-d60b34e50426
adegeo
approved these changes
Jul 15, 2026
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 #54658
Updates the extension members tutorial to cover the C# 15 addition of extension indexers.
Changes
net11.0) with<LangVersion>preview</LangVersion>; added a prerequisites note and a project-file step.Pathtype storing(dX, dY)offsets, then adds an extension indexer whose:Pointat an index by summing offsets fromPoint.Origin(reuses the static extension property and+operator introduced earlier in the tutorial), andPath.cs; newPathType,PathIndexer, andPathIndexerUsesnippet regions; demo method invoked end to end.Verification
dotnet buildanddotnet runsucceed on the .NET 11 preview SDK.:::code id="...":::references resolve to existing regions.Internal previews