-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Update csharp for preview 7 #9996
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,12 +2,43 @@ | |
|
|
||
| Here's a summary of what's new in C# in this preview release: | ||
|
|
||
| - [Feature](#feature) | ||
| - [Extension operators](#extension-operators) | ||
| - [Named and optional arguments in expression trees](#named-and-optiona) | ||
|
|
||
| Preview 7 represents feature complete for C# 14. Any features available only in later previews will be gated behind feature flags. That enables a longer feedback cycle for any additional features. | ||
|
|
||
| C# updates in .NET 10: | ||
|
|
||
| - [What's new in C# 13](https://learn.microsoft.com/dotnet/csharp/whats-new/csharp-13) documentation | ||
| - [What's new in C# 14](https://learn.microsoft.com/dotnet/csharp/whats-new/csharp-13) documentation | ||
jongalloway marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - [Breaking changes in C# 14](https://learn.microsoft.com/dotnet/csharp/whats-new/breaking-changes/compiler%20breaking%20changes%20-%20dotnet%2010) | ||
|
|
||
| ## Extension operators | ||
|
|
||
| The new extension blocks now include support for *operators*, with the exception of implicit and explicit conversion operators. You can declare operators in extension blocks, as shown in the following example: | ||
|
|
||
| ```csharp | ||
| public static class Operators | ||
| { | ||
| extension<TElement>(TElement[] source) where TElement : INumber<TElement> | ||
| { | ||
| public static TElement[] operator *(TElement[] vector, TElement scalar) { ... } | ||
| public static TElement[] operator *(TElement scalar, TElement[] vector) { ... } | ||
| public void operator *=(TElement scalar) { ... } | ||
| public static bool operator ==(TElement[] left, TElement[] right) { ... } | ||
| public static bool operator !=(TElement[] left, TElement[] right) { ... } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| Several of the rules for extension operators are demonstrated in the preceding example: | ||
|
|
||
| - At least one of the operands must be the *extended type*, `TElement[]` in the preceding example. | ||
| - For operators that require pair-wise declarations, such as `==` and `!=` in the preceding example, both operators must be declared in the same static class. They are not required to be in the same `extension` container. | ||
| - Instance compound assignment operators, and instance increment and decrement operators are expected to mutate the current instance. Therefore reference type parameters must be passed by value and value type parameters must be passed by `ref`. These operators can't be declared when the extended type is an unconstrained type parameter. | ||
| - Extension operators, like other extension members, can't use the `abstract`, `virtual`, `override`, or `sealed` modifiers. This is consistent with other extension members. | ||
|
|
||
| Extension members are only considered for overload resolution when no applicable predefined or user defined non-extension members are found. | ||
|
|
||
| ## Feature | ||
| ## Named and optional parameters in expression trees | ||
|
|
||
| Something about the feature | ||
| This is a small feature that removes a limitation for *expression trees*. Code in expression trees no longer needs to declare arguments for all optional parameters. In addition, code in expression trees can include named arguments. The call rewriting orders named arguments and provides values for missing optional parameters. Query providers shouldn't need to make any adjustments for this support. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps this should talk about "code in lambda expressions that are converted to expression trees" for clarity? |
||
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.
Uh oh!
There was an error while loading. Please reload this page.