-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support parsing of checked user-defined operator declarations (#59504)
- Loading branch information
Showing
17 changed files
with
1,318 additions
and
215 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Checked user-defined operators | ||
===================================== | ||
|
||
C# should support defining `checked` variants of the following user-defined operators so that users can opt into or out of overflow behavior as appropriate: | ||
* The `++` and `--` unary operators (https://github.com/dotnet/csharplang/blob/main/spec/expressions.md#postfix-increment-and-decrement-operators and https://github.com/dotnet/csharplang/blob/main/spec/expressions.md#prefix-increment-and-decrement-operators). | ||
* The `-` unary operator (https://github.com/dotnet/csharplang/blob/main/spec/expressions.md#unary-minus-operator). | ||
* The `+`, `-`, `*`, and `/` binary operators (https://github.com/dotnet/csharplang/blob/main/spec/expressions.md#arithmetic-operators). | ||
* Explicit conversion operators. | ||
|
||
Proposal: | ||
- https://github.com/dotnet/csharplang/issues/4665 | ||
- https://github.com/dotnet/csharplang/blob/main/proposals/checked-user-defined-operators.md | ||
|
||
Feature branch: https://github.com/dotnet/roslyn/tree/features/CheckedUserDefinedOperators | ||
|
||
Test plan: https://github.com/dotnet/roslyn/issues/59458 |
10 changes: 5 additions & 5 deletions
10
src/Compilers/CSharp/Portable/Generated/CSharp.Generated.g4
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
358 changes: 256 additions & 102 deletions
358
...arpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Internal.Generated.cs
Large diffs are not rendered by default.
Oops, something went wrong.
64 changes: 44 additions & 20 deletions
64
.../CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Main.Generated.cs
Large diffs are not rendered by default.
Oops, something went wrong.
188 changes: 115 additions & 73 deletions
188
...SharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Syntax.Generated.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
19 changes: 19 additions & 0 deletions
19
src/Compilers/CSharp/Portable/Syntax/ConversionOperatorMemberCrefSyntax.cs
This file contains 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace Microsoft.CodeAnalysis.CSharp.Syntax | ||
{ | ||
public partial class ConversionOperatorMemberCrefSyntax | ||
{ | ||
public ConversionOperatorMemberCrefSyntax Update(SyntaxToken implicitOrExplicitKeyword, SyntaxToken operatorKeyword, TypeSyntax type, CrefParameterListSyntax? parameters) | ||
{ | ||
return Update( | ||
implicitOrExplicitKeyword: implicitOrExplicitKeyword, | ||
operatorKeyword: operatorKeyword, | ||
checkedKeyword: this.CheckedKeyword, | ||
type: type, | ||
parameters: parameters); | ||
} | ||
} | ||
} |
This file contains 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
18 changes: 18 additions & 0 deletions
18
src/Compilers/CSharp/Portable/Syntax/OperatorMemberCrefSyntax.cs
This file contains 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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace Microsoft.CodeAnalysis.CSharp.Syntax | ||
{ | ||
public partial class OperatorMemberCrefSyntax | ||
{ | ||
public OperatorMemberCrefSyntax Update(SyntaxToken operatorKeyword, SyntaxToken operatorToken, CrefParameterListSyntax? parameters) | ||
{ | ||
return Update( | ||
operatorKeyword: operatorKeyword, | ||
checkedKeyword: this.CheckedKeyword, | ||
operatorToken: operatorToken, | ||
parameters: parameters); | ||
} | ||
} | ||
} |
Oops, something went wrong.