-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Replace extension method with member #50113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Where samples use `this` extension methods, except where explaining the `this` syntax, convert to the C# 14 extension member syntax,
This adds all the folders *except* tutorials and LINQ. (Those will be in separate PRs)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates C# documentation to replace references to "extension method" with "extension member" terminology, reflecting the C# 14 syntax changes that introduce extension blocks supporting properties, operators, and static extensions in addition to traditional extension methods.
Key changes include:
- Terminology update from "extension method(s)" to "extension member(s)" across 18 documentation files
- Code sample migration in CallerInformation.cs to demonstrate C# 14 extension member syntax
- Target framework updates from net8.0/net9.0 to net10.0 in project files
- Grammar improvements including contraction usage per style guidelines
- Removal of unused code examples in GenericWhereConstraints.cs
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/csharp/roslyn-sdk/work-with-syntax.md | Updated terminology from "extension methods" to "extension members" |
| docs/csharp/roslyn-sdk/tutorials/how-to-write-csharp-analyzer-code-fix.md | Updated terminology for GetDeclaredSymbol extension member reference |
| docs/csharp/roslyn-sdk/get-started/syntax-transformation.md | Updated ReplaceNode reference from extension method to extension member |
| docs/csharp/methods.md | Changed heading and content to reference extension members; includes problematic "comprise" word choice |
| docs/csharp/language-reference/statements/yield.md | Fixed "can not" to "can't" contraction; updated ms.date |
| docs/csharp/language-reference/statements/iteration-statements.md | Updated foreach and await foreach extension member references; includes problematic "may/can" changes |
| docs/csharp/language-reference/operators/member-access-operators.md | Updated dot operator description to reference extension members |
| docs/csharp/language-reference/operators/deconstruction.md | Updated Deconstruct extension member references; contains date typo (2024 vs 2025) |
| docs/csharp/language-reference/keywords/where-generic-type-constraint.md | Fixed "does not" to "doesn't" contraction |
| docs/csharp/language-reference/keywords/using-directive.md | Updated using static directive extension member references; fixed "is not" to "isn't" |
| docs/csharp/language-reference/keywords/this.md | Clarified distinction between this for current instance vs extension method usage |
| docs/csharp/language-reference/keywords/snippets/Program.cs | Removed commented-out test code calls |
| docs/csharp/language-reference/keywords/snippets/GenericWhereConstraints.cs | Removed unused example code and using statements |
| docs/csharp/language-reference/keywords/method-parameters.md | Updated extension member parameter restriction documentation |
| docs/csharp/language-reference/compiler-messages/cs0122.md | Updated access modifier error message for extension members |
| docs/csharp/language-reference/builtin-types/enum.md | Updated extension member reference; fixed contractions; includes questionable content changes |
| docs/csharp/language-reference/builtin-types/built-in-types.md | Updated implicit span conversion extension member reference |
| docs/csharp/language-reference/attributes/snippets/attributes.csproj | Updated target framework from net9.0 to net10.0 |
| docs/csharp/language-reference/attributes/snippets/CallerInformation.cs | Critical: Attempted migration to C# 14 extension member syntax with syntax errors |
| docs/csharp/language-reference/attributes/caller-information.md | Updated CallerArgumentExpression extension member reference |
| docs/csharp/how-to/index.md | Updated how-to links to reference extension members; inconsistent singular/plural usage |
| docs/csharp/advanced-topics/interface-implementation/snippets/mixins-with-default-interface-methods/mixins-with-interfaces.csproj | Updated target framework from net8.0 to net10.0 |
| docs/csharp/advanced-topics/interface-implementation/mixins-with-default-interface-methods.md | Updated tutorial content to use extension member terminology; includes unnecessary grammatical changes |
docs/csharp/advanced-topics/interface-implementation/mixins-with-default-interface-methods.md
Outdated
Show resolved
Hide resolved
docs/csharp/language-reference/keywords/where-generic-type-constraint.md
Show resolved
Hide resolved
docs/csharp/language-reference/statements/iteration-statements.md
Outdated
Show resolved
Hide resolved
docs/csharp/advanced-topics/interface-implementation/mixins-with-default-interface-methods.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <[email protected]>
|
Adding @gewarren Do we want to do anything similar with snippets in the API Reference repo? |
docs/csharp/language-reference/statements/iteration-statements.md
Outdated
Show resolved
Hide resolved
docs/csharp/language-reference/statements/iteration-statements.md
Outdated
Show resolved
Hide resolved
Is this the recommended way to declare extension methods going forward? |
It's a very mild recommendation. The primary driver to use the new syntax is to enable extension operators and extension properties. (More extension member types are planned). So, like string interpolation, or raw string literals, we want C# developers to see the new syntax more often, and use it, there's no motivation to replace existing methods. The runtime team likely won't update existing extension methods to use the new syntax without other motivating work like adding extension operators to an existing extension library. For us, how closely do we want our sample code to match the runtime source? |
In that case, I don't think we need to go through and update the existing samples in dotnet-api-docs. There are other more glaring things that might be higher priority to fix (like using exception helpers). |
Co-authored-by: Genevieve Warren <[email protected]>
Contributes to #45758
Where samples use
thisextension methods, except where explaining thethissyntax, convert to the C# 14 extension member syntax,This PR doesn't include the tutorials, or LINQ sub-folders in the C# Guide. Those will be in a separate PR.
Internal previews
Toggle expand/collapse
usingdirective