diff --git a/docs/features/CheckedUserDefinedOperators.md b/docs/features/CheckedUserDefinedOperators.md new file mode 100644 index 0000000000000..6a001ba5255b4 --- /dev/null +++ b/docs/features/CheckedUserDefinedOperators.md @@ -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 diff --git a/src/Compilers/CSharp/Portable/Generated/CSharp.Generated.g4 b/src/Compilers/CSharp/Portable/Generated/CSharp.Generated.g4 index 47a98c6fef76f..b181abbb7500f 100644 --- a/src/Compilers/CSharp/Portable/Generated/CSharp.Generated.g4 +++ b/src/Compilers/CSharp/Portable/Generated/CSharp.Generated.g4 @@ -177,7 +177,7 @@ arrow_expression_clause ; conversion_operator_declaration - : attribute_list* modifier* ('implicit' | 'explicit') explicit_interface_specifier? 'operator' type parameter_list (block | (arrow_expression_clause ';')) + : attribute_list* modifier* ('implicit' | 'explicit') explicit_interface_specifier? 'operator' 'checked'? type parameter_list (block | (arrow_expression_clause ';')) ; explicit_interface_specifier @@ -229,7 +229,7 @@ type_constraint ; operator_declaration - : attribute_list* modifier* type explicit_interface_specifier? 'operator' ('+' | '-' | '!' | '~' | '++' | '--' | '*' | '/' | '%' | '<<' | '>>' | '|' | '&' | '^' | '==' | '!=' | '<' | '<=' | '>' | '>=' | 'false' | 'true' | 'is') parameter_list (block | (arrow_expression_clause ';')) + : attribute_list* modifier* type explicit_interface_specifier? 'operator' 'checked'? ('+' | '-' | '!' | '~' | '++' | '--' | '*' | '/' | '%' | '<<' | '>>' | '|' | '&' | '^' | '==' | '!=' | '<' | '<=' | '>' | '>=' | 'false' | 'true' | 'is') parameter_list (block | (arrow_expression_clause ';')) ; base_namespace_declaration @@ -1128,8 +1128,8 @@ member_cref ; conversion_operator_member_cref - : 'explicit' 'operator' type cref_parameter_list? - | 'implicit' 'operator' type cref_parameter_list? + : 'explicit' 'operator' 'checked'? type cref_parameter_list? + | 'implicit' 'operator' 'checked'? type cref_parameter_list? ; cref_parameter_list @@ -1155,7 +1155,7 @@ name_member_cref ; operator_member_cref - : 'operator' ('+' | '-' | '!' | '~' | '++' | '--' | '*' | '/' | '%' | '<<' | '>>' | '|' | '&' | '^' | '==' | '!=' | '<' | '<=' | '>' | '>=' | 'false' | 'true') cref_parameter_list? + : 'operator' 'checked'? ('+' | '-' | '!' | '~' | '++' | '--' | '*' | '/' | '%' | '<<' | '>>' | '|' | '&' | '^' | '==' | '!=' | '<' | '<=' | '>' | '>=' | 'false' | 'true') cref_parameter_list? ; qualified_cref diff --git a/src/Compilers/CSharp/Portable/Generated/CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Internal.Generated.cs b/src/Compilers/CSharp/Portable/Generated/CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Internal.Generated.cs index 873f32575465f..314169a8990cc 100644 --- a/src/Compilers/CSharp/Portable/Generated/CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Internal.Generated.cs +++ b/src/Compilers/CSharp/Portable/Generated/CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Internal.Generated.cs @@ -25009,16 +25009,17 @@ internal sealed partial class OperatorDeclarationSyntax : BaseMethodDeclarationS internal readonly TypeSyntax returnType; internal readonly ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier; internal readonly SyntaxToken operatorKeyword; + internal readonly SyntaxToken? checkedKeyword; internal readonly SyntaxToken operatorToken; internal readonly ParameterListSyntax parameterList; internal readonly BlockSyntax? body; internal readonly ArrowExpressionClauseSyntax? expressionBody; internal readonly SyntaxToken? semicolonToken; - internal OperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attributeLists, GreenNode? modifiers, TypeSyntax returnType, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, SyntaxToken operatorToken, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken, DiagnosticInfo[]? diagnostics, SyntaxAnnotation[]? annotations) + internal OperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attributeLists, GreenNode? modifiers, TypeSyntax returnType, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, SyntaxToken? checkedKeyword, SyntaxToken operatorToken, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken, DiagnosticInfo[]? diagnostics, SyntaxAnnotation[]? annotations) : base(kind, diagnostics, annotations) { - this.SlotCount = 10; + this.SlotCount = 11; if (attributeLists != null) { this.AdjustFlagsAndWidth(attributeLists); @@ -25038,6 +25039,11 @@ internal OperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attributeLists, G } this.AdjustFlagsAndWidth(operatorKeyword); this.operatorKeyword = operatorKeyword; + if (checkedKeyword != null) + { + this.AdjustFlagsAndWidth(checkedKeyword); + this.checkedKeyword = checkedKeyword; + } this.AdjustFlagsAndWidth(operatorToken); this.operatorToken = operatorToken; this.AdjustFlagsAndWidth(parameterList); @@ -25059,11 +25065,11 @@ internal OperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attributeLists, G } } - internal OperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attributeLists, GreenNode? modifiers, TypeSyntax returnType, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, SyntaxToken operatorToken, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken, SyntaxFactoryContext context) + internal OperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attributeLists, GreenNode? modifiers, TypeSyntax returnType, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, SyntaxToken? checkedKeyword, SyntaxToken operatorToken, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken, SyntaxFactoryContext context) : base(kind) { this.SetFactoryContext(context); - this.SlotCount = 10; + this.SlotCount = 11; if (attributeLists != null) { this.AdjustFlagsAndWidth(attributeLists); @@ -25083,6 +25089,11 @@ internal OperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attributeLists, G } this.AdjustFlagsAndWidth(operatorKeyword); this.operatorKeyword = operatorKeyword; + if (checkedKeyword != null) + { + this.AdjustFlagsAndWidth(checkedKeyword); + this.checkedKeyword = checkedKeyword; + } this.AdjustFlagsAndWidth(operatorToken); this.operatorToken = operatorToken; this.AdjustFlagsAndWidth(parameterList); @@ -25104,10 +25115,10 @@ internal OperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attributeLists, G } } - internal OperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attributeLists, GreenNode? modifiers, TypeSyntax returnType, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, SyntaxToken operatorToken, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken) + internal OperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attributeLists, GreenNode? modifiers, TypeSyntax returnType, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, SyntaxToken? checkedKeyword, SyntaxToken operatorToken, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken) : base(kind) { - this.SlotCount = 10; + this.SlotCount = 11; if (attributeLists != null) { this.AdjustFlagsAndWidth(attributeLists); @@ -25127,6 +25138,11 @@ internal OperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attributeLists, G } this.AdjustFlagsAndWidth(operatorKeyword); this.operatorKeyword = operatorKeyword; + if (checkedKeyword != null) + { + this.AdjustFlagsAndWidth(checkedKeyword); + this.checkedKeyword = checkedKeyword; + } this.AdjustFlagsAndWidth(operatorToken); this.operatorToken = operatorToken; this.AdjustFlagsAndWidth(parameterList); @@ -25155,6 +25171,8 @@ internal OperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attributeLists, G public ExplicitInterfaceSpecifierSyntax? ExplicitInterfaceSpecifier => this.explicitInterfaceSpecifier; /// Gets the "operator" keyword. public SyntaxToken OperatorKeyword => this.operatorKeyword; + /// Gets the "checked" keyword. + public SyntaxToken? CheckedKeyword => this.checkedKeyword; /// Gets the operator token. public SyntaxToken OperatorToken => this.operatorToken; public override ParameterListSyntax ParameterList => this.parameterList; @@ -25171,11 +25189,12 @@ internal OperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attributeLists, G 2 => this.returnType, 3 => this.explicitInterfaceSpecifier, 4 => this.operatorKeyword, - 5 => this.operatorToken, - 6 => this.parameterList, - 7 => this.body, - 8 => this.expressionBody, - 9 => this.semicolonToken, + 5 => this.checkedKeyword, + 6 => this.operatorToken, + 7 => this.parameterList, + 8 => this.body, + 9 => this.expressionBody, + 10 => this.semicolonToken, _ => null, }; @@ -25184,11 +25203,11 @@ internal OperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attributeLists, G public override void Accept(CSharpSyntaxVisitor visitor) => visitor.VisitOperatorDeclaration(this); public override TResult Accept(CSharpSyntaxVisitor visitor) => visitor.VisitOperatorDeclaration(this); - public OperatorDeclarationSyntax Update(Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList attributeLists, Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList modifiers, TypeSyntax returnType, ExplicitInterfaceSpecifierSyntax explicitInterfaceSpecifier, SyntaxToken operatorKeyword, SyntaxToken operatorToken, ParameterListSyntax parameterList, BlockSyntax body, ArrowExpressionClauseSyntax expressionBody, SyntaxToken semicolonToken) + public OperatorDeclarationSyntax Update(Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList attributeLists, Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList modifiers, TypeSyntax returnType, ExplicitInterfaceSpecifierSyntax explicitInterfaceSpecifier, SyntaxToken operatorKeyword, SyntaxToken checkedKeyword, SyntaxToken operatorToken, ParameterListSyntax parameterList, BlockSyntax body, ArrowExpressionClauseSyntax expressionBody, SyntaxToken semicolonToken) { - if (attributeLists != this.AttributeLists || modifiers != this.Modifiers || returnType != this.ReturnType || explicitInterfaceSpecifier != this.ExplicitInterfaceSpecifier || operatorKeyword != this.OperatorKeyword || operatorToken != this.OperatorToken || parameterList != this.ParameterList || body != this.Body || expressionBody != this.ExpressionBody || semicolonToken != this.SemicolonToken) + if (attributeLists != this.AttributeLists || modifiers != this.Modifiers || returnType != this.ReturnType || explicitInterfaceSpecifier != this.ExplicitInterfaceSpecifier || operatorKeyword != this.OperatorKeyword || checkedKeyword != this.CheckedKeyword || operatorToken != this.OperatorToken || parameterList != this.ParameterList || body != this.Body || expressionBody != this.ExpressionBody || semicolonToken != this.SemicolonToken) { - var newNode = SyntaxFactory.OperatorDeclaration(attributeLists, modifiers, returnType, explicitInterfaceSpecifier, operatorKeyword, operatorToken, parameterList, body, expressionBody, semicolonToken); + var newNode = SyntaxFactory.OperatorDeclaration(attributeLists, modifiers, returnType, explicitInterfaceSpecifier, operatorKeyword, checkedKeyword, operatorToken, parameterList, body, expressionBody, semicolonToken); var diags = GetDiagnostics(); if (diags?.Length > 0) newNode = newNode.WithDiagnosticsGreen(diags); @@ -25202,15 +25221,15 @@ public OperatorDeclarationSyntax Update(Microsoft.CodeAnalysis.Syntax.InternalSy } internal override GreenNode SetDiagnostics(DiagnosticInfo[]? diagnostics) - => new OperatorDeclarationSyntax(this.Kind, this.attributeLists, this.modifiers, this.returnType, this.explicitInterfaceSpecifier, this.operatorKeyword, this.operatorToken, this.parameterList, this.body, this.expressionBody, this.semicolonToken, diagnostics, GetAnnotations()); + => new OperatorDeclarationSyntax(this.Kind, this.attributeLists, this.modifiers, this.returnType, this.explicitInterfaceSpecifier, this.operatorKeyword, this.checkedKeyword, this.operatorToken, this.parameterList, this.body, this.expressionBody, this.semicolonToken, diagnostics, GetAnnotations()); internal override GreenNode SetAnnotations(SyntaxAnnotation[]? annotations) - => new OperatorDeclarationSyntax(this.Kind, this.attributeLists, this.modifiers, this.returnType, this.explicitInterfaceSpecifier, this.operatorKeyword, this.operatorToken, this.parameterList, this.body, this.expressionBody, this.semicolonToken, GetDiagnostics(), annotations); + => new OperatorDeclarationSyntax(this.Kind, this.attributeLists, this.modifiers, this.returnType, this.explicitInterfaceSpecifier, this.operatorKeyword, this.checkedKeyword, this.operatorToken, this.parameterList, this.body, this.expressionBody, this.semicolonToken, GetDiagnostics(), annotations); internal OperatorDeclarationSyntax(ObjectReader reader) : base(reader) { - this.SlotCount = 10; + this.SlotCount = 11; var attributeLists = (GreenNode?)reader.ReadValue(); if (attributeLists != null) { @@ -25235,6 +25254,12 @@ internal OperatorDeclarationSyntax(ObjectReader reader) var operatorKeyword = (SyntaxToken)reader.ReadValue(); AdjustFlagsAndWidth(operatorKeyword); this.operatorKeyword = operatorKeyword; + var checkedKeyword = (SyntaxToken?)reader.ReadValue(); + if (checkedKeyword != null) + { + AdjustFlagsAndWidth(checkedKeyword); + this.checkedKeyword = checkedKeyword; + } var operatorToken = (SyntaxToken)reader.ReadValue(); AdjustFlagsAndWidth(operatorToken); this.operatorToken = operatorToken; @@ -25269,6 +25294,7 @@ internal override void WriteTo(ObjectWriter writer) writer.WriteValue(this.returnType); writer.WriteValue(this.explicitInterfaceSpecifier); writer.WriteValue(this.operatorKeyword); + writer.WriteValue(this.checkedKeyword); writer.WriteValue(this.operatorToken); writer.WriteValue(this.parameterList); writer.WriteValue(this.body); @@ -25290,16 +25316,17 @@ internal sealed partial class ConversionOperatorDeclarationSyntax : BaseMethodDe internal readonly SyntaxToken implicitOrExplicitKeyword; internal readonly ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier; internal readonly SyntaxToken operatorKeyword; + internal readonly SyntaxToken? checkedKeyword; internal readonly TypeSyntax type; internal readonly ParameterListSyntax parameterList; internal readonly BlockSyntax? body; internal readonly ArrowExpressionClauseSyntax? expressionBody; internal readonly SyntaxToken? semicolonToken; - internal ConversionOperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attributeLists, GreenNode? modifiers, SyntaxToken implicitOrExplicitKeyword, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, TypeSyntax type, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken, DiagnosticInfo[]? diagnostics, SyntaxAnnotation[]? annotations) + internal ConversionOperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attributeLists, GreenNode? modifiers, SyntaxToken implicitOrExplicitKeyword, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, SyntaxToken? checkedKeyword, TypeSyntax type, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken, DiagnosticInfo[]? diagnostics, SyntaxAnnotation[]? annotations) : base(kind, diagnostics, annotations) { - this.SlotCount = 10; + this.SlotCount = 11; if (attributeLists != null) { this.AdjustFlagsAndWidth(attributeLists); @@ -25319,6 +25346,11 @@ internal ConversionOperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attribu } this.AdjustFlagsAndWidth(operatorKeyword); this.operatorKeyword = operatorKeyword; + if (checkedKeyword != null) + { + this.AdjustFlagsAndWidth(checkedKeyword); + this.checkedKeyword = checkedKeyword; + } this.AdjustFlagsAndWidth(type); this.type = type; this.AdjustFlagsAndWidth(parameterList); @@ -25340,11 +25372,11 @@ internal ConversionOperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attribu } } - internal ConversionOperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attributeLists, GreenNode? modifiers, SyntaxToken implicitOrExplicitKeyword, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, TypeSyntax type, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken, SyntaxFactoryContext context) + internal ConversionOperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attributeLists, GreenNode? modifiers, SyntaxToken implicitOrExplicitKeyword, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, SyntaxToken? checkedKeyword, TypeSyntax type, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken, SyntaxFactoryContext context) : base(kind) { this.SetFactoryContext(context); - this.SlotCount = 10; + this.SlotCount = 11; if (attributeLists != null) { this.AdjustFlagsAndWidth(attributeLists); @@ -25364,6 +25396,11 @@ internal ConversionOperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attribu } this.AdjustFlagsAndWidth(operatorKeyword); this.operatorKeyword = operatorKeyword; + if (checkedKeyword != null) + { + this.AdjustFlagsAndWidth(checkedKeyword); + this.checkedKeyword = checkedKeyword; + } this.AdjustFlagsAndWidth(type); this.type = type; this.AdjustFlagsAndWidth(parameterList); @@ -25385,10 +25422,10 @@ internal ConversionOperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attribu } } - internal ConversionOperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attributeLists, GreenNode? modifiers, SyntaxToken implicitOrExplicitKeyword, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, TypeSyntax type, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken) + internal ConversionOperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attributeLists, GreenNode? modifiers, SyntaxToken implicitOrExplicitKeyword, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, SyntaxToken? checkedKeyword, TypeSyntax type, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken) : base(kind) { - this.SlotCount = 10; + this.SlotCount = 11; if (attributeLists != null) { this.AdjustFlagsAndWidth(attributeLists); @@ -25408,6 +25445,11 @@ internal ConversionOperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attribu } this.AdjustFlagsAndWidth(operatorKeyword); this.operatorKeyword = operatorKeyword; + if (checkedKeyword != null) + { + this.AdjustFlagsAndWidth(checkedKeyword); + this.checkedKeyword = checkedKeyword; + } this.AdjustFlagsAndWidth(type); this.type = type; this.AdjustFlagsAndWidth(parameterList); @@ -25436,6 +25478,8 @@ internal ConversionOperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attribu public ExplicitInterfaceSpecifierSyntax? ExplicitInterfaceSpecifier => this.explicitInterfaceSpecifier; /// Gets the "operator" token. public SyntaxToken OperatorKeyword => this.operatorKeyword; + /// Gets the "checked" keyword. + public SyntaxToken? CheckedKeyword => this.checkedKeyword; /// Gets the type. public TypeSyntax Type => this.type; public override ParameterListSyntax ParameterList => this.parameterList; @@ -25452,11 +25496,12 @@ internal ConversionOperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attribu 2 => this.implicitOrExplicitKeyword, 3 => this.explicitInterfaceSpecifier, 4 => this.operatorKeyword, - 5 => this.type, - 6 => this.parameterList, - 7 => this.body, - 8 => this.expressionBody, - 9 => this.semicolonToken, + 5 => this.checkedKeyword, + 6 => this.type, + 7 => this.parameterList, + 8 => this.body, + 9 => this.expressionBody, + 10 => this.semicolonToken, _ => null, }; @@ -25465,11 +25510,11 @@ internal ConversionOperatorDeclarationSyntax(SyntaxKind kind, GreenNode? attribu public override void Accept(CSharpSyntaxVisitor visitor) => visitor.VisitConversionOperatorDeclaration(this); public override TResult Accept(CSharpSyntaxVisitor visitor) => visitor.VisitConversionOperatorDeclaration(this); - public ConversionOperatorDeclarationSyntax Update(Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList attributeLists, Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList modifiers, SyntaxToken implicitOrExplicitKeyword, ExplicitInterfaceSpecifierSyntax explicitInterfaceSpecifier, SyntaxToken operatorKeyword, TypeSyntax type, ParameterListSyntax parameterList, BlockSyntax body, ArrowExpressionClauseSyntax expressionBody, SyntaxToken semicolonToken) + public ConversionOperatorDeclarationSyntax Update(Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList attributeLists, Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList modifiers, SyntaxToken implicitOrExplicitKeyword, ExplicitInterfaceSpecifierSyntax explicitInterfaceSpecifier, SyntaxToken operatorKeyword, SyntaxToken checkedKeyword, TypeSyntax type, ParameterListSyntax parameterList, BlockSyntax body, ArrowExpressionClauseSyntax expressionBody, SyntaxToken semicolonToken) { - if (attributeLists != this.AttributeLists || modifiers != this.Modifiers || implicitOrExplicitKeyword != this.ImplicitOrExplicitKeyword || explicitInterfaceSpecifier != this.ExplicitInterfaceSpecifier || operatorKeyword != this.OperatorKeyword || type != this.Type || parameterList != this.ParameterList || body != this.Body || expressionBody != this.ExpressionBody || semicolonToken != this.SemicolonToken) + if (attributeLists != this.AttributeLists || modifiers != this.Modifiers || implicitOrExplicitKeyword != this.ImplicitOrExplicitKeyword || explicitInterfaceSpecifier != this.ExplicitInterfaceSpecifier || operatorKeyword != this.OperatorKeyword || checkedKeyword != this.CheckedKeyword || type != this.Type || parameterList != this.ParameterList || body != this.Body || expressionBody != this.ExpressionBody || semicolonToken != this.SemicolonToken) { - var newNode = SyntaxFactory.ConversionOperatorDeclaration(attributeLists, modifiers, implicitOrExplicitKeyword, explicitInterfaceSpecifier, operatorKeyword, type, parameterList, body, expressionBody, semicolonToken); + var newNode = SyntaxFactory.ConversionOperatorDeclaration(attributeLists, modifiers, implicitOrExplicitKeyword, explicitInterfaceSpecifier, operatorKeyword, checkedKeyword, type, parameterList, body, expressionBody, semicolonToken); var diags = GetDiagnostics(); if (diags?.Length > 0) newNode = newNode.WithDiagnosticsGreen(diags); @@ -25483,15 +25528,15 @@ public ConversionOperatorDeclarationSyntax Update(Microsoft.CodeAnalysis.Syntax. } internal override GreenNode SetDiagnostics(DiagnosticInfo[]? diagnostics) - => new ConversionOperatorDeclarationSyntax(this.Kind, this.attributeLists, this.modifiers, this.implicitOrExplicitKeyword, this.explicitInterfaceSpecifier, this.operatorKeyword, this.type, this.parameterList, this.body, this.expressionBody, this.semicolonToken, diagnostics, GetAnnotations()); + => new ConversionOperatorDeclarationSyntax(this.Kind, this.attributeLists, this.modifiers, this.implicitOrExplicitKeyword, this.explicitInterfaceSpecifier, this.operatorKeyword, this.checkedKeyword, this.type, this.parameterList, this.body, this.expressionBody, this.semicolonToken, diagnostics, GetAnnotations()); internal override GreenNode SetAnnotations(SyntaxAnnotation[]? annotations) - => new ConversionOperatorDeclarationSyntax(this.Kind, this.attributeLists, this.modifiers, this.implicitOrExplicitKeyword, this.explicitInterfaceSpecifier, this.operatorKeyword, this.type, this.parameterList, this.body, this.expressionBody, this.semicolonToken, GetDiagnostics(), annotations); + => new ConversionOperatorDeclarationSyntax(this.Kind, this.attributeLists, this.modifiers, this.implicitOrExplicitKeyword, this.explicitInterfaceSpecifier, this.operatorKeyword, this.checkedKeyword, this.type, this.parameterList, this.body, this.expressionBody, this.semicolonToken, GetDiagnostics(), annotations); internal ConversionOperatorDeclarationSyntax(ObjectReader reader) : base(reader) { - this.SlotCount = 10; + this.SlotCount = 11; var attributeLists = (GreenNode?)reader.ReadValue(); if (attributeLists != null) { @@ -25516,6 +25561,12 @@ internal ConversionOperatorDeclarationSyntax(ObjectReader reader) var operatorKeyword = (SyntaxToken)reader.ReadValue(); AdjustFlagsAndWidth(operatorKeyword); this.operatorKeyword = operatorKeyword; + var checkedKeyword = (SyntaxToken?)reader.ReadValue(); + if (checkedKeyword != null) + { + AdjustFlagsAndWidth(checkedKeyword); + this.checkedKeyword = checkedKeyword; + } var type = (TypeSyntax)reader.ReadValue(); AdjustFlagsAndWidth(type); this.type = type; @@ -25550,6 +25601,7 @@ internal override void WriteTo(ObjectWriter writer) writer.WriteValue(this.implicitOrExplicitKeyword); writer.WriteValue(this.explicitInterfaceSpecifier); writer.WriteValue(this.operatorKeyword); + writer.WriteValue(this.checkedKeyword); writer.WriteValue(this.type); writer.WriteValue(this.parameterList); writer.WriteValue(this.body); @@ -28940,15 +28992,21 @@ static IndexerMemberCrefSyntax() internal sealed partial class OperatorMemberCrefSyntax : MemberCrefSyntax { internal readonly SyntaxToken operatorKeyword; + internal readonly SyntaxToken? checkedKeyword; internal readonly SyntaxToken operatorToken; internal readonly CrefParameterListSyntax? parameters; - internal OperatorMemberCrefSyntax(SyntaxKind kind, SyntaxToken operatorKeyword, SyntaxToken operatorToken, CrefParameterListSyntax? parameters, DiagnosticInfo[]? diagnostics, SyntaxAnnotation[]? annotations) + internal OperatorMemberCrefSyntax(SyntaxKind kind, SyntaxToken operatorKeyword, SyntaxToken? checkedKeyword, SyntaxToken operatorToken, CrefParameterListSyntax? parameters, DiagnosticInfo[]? diagnostics, SyntaxAnnotation[]? annotations) : base(kind, diagnostics, annotations) { - this.SlotCount = 3; + this.SlotCount = 4; this.AdjustFlagsAndWidth(operatorKeyword); this.operatorKeyword = operatorKeyword; + if (checkedKeyword != null) + { + this.AdjustFlagsAndWidth(checkedKeyword); + this.checkedKeyword = checkedKeyword; + } this.AdjustFlagsAndWidth(operatorToken); this.operatorToken = operatorToken; if (parameters != null) @@ -28958,13 +29016,18 @@ internal OperatorMemberCrefSyntax(SyntaxKind kind, SyntaxToken operatorKeyword, } } - internal OperatorMemberCrefSyntax(SyntaxKind kind, SyntaxToken operatorKeyword, SyntaxToken operatorToken, CrefParameterListSyntax? parameters, SyntaxFactoryContext context) + internal OperatorMemberCrefSyntax(SyntaxKind kind, SyntaxToken operatorKeyword, SyntaxToken? checkedKeyword, SyntaxToken operatorToken, CrefParameterListSyntax? parameters, SyntaxFactoryContext context) : base(kind) { this.SetFactoryContext(context); - this.SlotCount = 3; + this.SlotCount = 4; this.AdjustFlagsAndWidth(operatorKeyword); this.operatorKeyword = operatorKeyword; + if (checkedKeyword != null) + { + this.AdjustFlagsAndWidth(checkedKeyword); + this.checkedKeyword = checkedKeyword; + } this.AdjustFlagsAndWidth(operatorToken); this.operatorToken = operatorToken; if (parameters != null) @@ -28974,12 +29037,17 @@ internal OperatorMemberCrefSyntax(SyntaxKind kind, SyntaxToken operatorKeyword, } } - internal OperatorMemberCrefSyntax(SyntaxKind kind, SyntaxToken operatorKeyword, SyntaxToken operatorToken, CrefParameterListSyntax? parameters) + internal OperatorMemberCrefSyntax(SyntaxKind kind, SyntaxToken operatorKeyword, SyntaxToken? checkedKeyword, SyntaxToken operatorToken, CrefParameterListSyntax? parameters) : base(kind) { - this.SlotCount = 3; + this.SlotCount = 4; this.AdjustFlagsAndWidth(operatorKeyword); this.operatorKeyword = operatorKeyword; + if (checkedKeyword != null) + { + this.AdjustFlagsAndWidth(checkedKeyword); + this.checkedKeyword = checkedKeyword; + } this.AdjustFlagsAndWidth(operatorToken); this.operatorToken = operatorToken; if (parameters != null) @@ -28990,6 +29058,7 @@ internal OperatorMemberCrefSyntax(SyntaxKind kind, SyntaxToken operatorKeyword, } public SyntaxToken OperatorKeyword => this.operatorKeyword; + public SyntaxToken? CheckedKeyword => this.checkedKeyword; /// Gets the operator token. public SyntaxToken OperatorToken => this.operatorToken; public CrefParameterListSyntax? Parameters => this.parameters; @@ -28998,8 +29067,9 @@ internal OperatorMemberCrefSyntax(SyntaxKind kind, SyntaxToken operatorKeyword, => index switch { 0 => this.operatorKeyword, - 1 => this.operatorToken, - 2 => this.parameters, + 1 => this.checkedKeyword, + 2 => this.operatorToken, + 3 => this.parameters, _ => null, }; @@ -29008,11 +29078,11 @@ internal OperatorMemberCrefSyntax(SyntaxKind kind, SyntaxToken operatorKeyword, public override void Accept(CSharpSyntaxVisitor visitor) => visitor.VisitOperatorMemberCref(this); public override TResult Accept(CSharpSyntaxVisitor visitor) => visitor.VisitOperatorMemberCref(this); - public OperatorMemberCrefSyntax Update(SyntaxToken operatorKeyword, SyntaxToken operatorToken, CrefParameterListSyntax parameters) + public OperatorMemberCrefSyntax Update(SyntaxToken operatorKeyword, SyntaxToken checkedKeyword, SyntaxToken operatorToken, CrefParameterListSyntax parameters) { - if (operatorKeyword != this.OperatorKeyword || operatorToken != this.OperatorToken || parameters != this.Parameters) + if (operatorKeyword != this.OperatorKeyword || checkedKeyword != this.CheckedKeyword || operatorToken != this.OperatorToken || parameters != this.Parameters) { - var newNode = SyntaxFactory.OperatorMemberCref(operatorKeyword, operatorToken, parameters); + var newNode = SyntaxFactory.OperatorMemberCref(operatorKeyword, checkedKeyword, operatorToken, parameters); var diags = GetDiagnostics(); if (diags?.Length > 0) newNode = newNode.WithDiagnosticsGreen(diags); @@ -29026,18 +29096,24 @@ public OperatorMemberCrefSyntax Update(SyntaxToken operatorKeyword, SyntaxToken } internal override GreenNode SetDiagnostics(DiagnosticInfo[]? diagnostics) - => new OperatorMemberCrefSyntax(this.Kind, this.operatorKeyword, this.operatorToken, this.parameters, diagnostics, GetAnnotations()); + => new OperatorMemberCrefSyntax(this.Kind, this.operatorKeyword, this.checkedKeyword, this.operatorToken, this.parameters, diagnostics, GetAnnotations()); internal override GreenNode SetAnnotations(SyntaxAnnotation[]? annotations) - => new OperatorMemberCrefSyntax(this.Kind, this.operatorKeyword, this.operatorToken, this.parameters, GetDiagnostics(), annotations); + => new OperatorMemberCrefSyntax(this.Kind, this.operatorKeyword, this.checkedKeyword, this.operatorToken, this.parameters, GetDiagnostics(), annotations); internal OperatorMemberCrefSyntax(ObjectReader reader) : base(reader) { - this.SlotCount = 3; + this.SlotCount = 4; var operatorKeyword = (SyntaxToken)reader.ReadValue(); AdjustFlagsAndWidth(operatorKeyword); this.operatorKeyword = operatorKeyword; + var checkedKeyword = (SyntaxToken?)reader.ReadValue(); + if (checkedKeyword != null) + { + AdjustFlagsAndWidth(checkedKeyword); + this.checkedKeyword = checkedKeyword; + } var operatorToken = (SyntaxToken)reader.ReadValue(); AdjustFlagsAndWidth(operatorToken); this.operatorToken = operatorToken; @@ -29053,6 +29129,7 @@ internal override void WriteTo(ObjectWriter writer) { base.WriteTo(writer); writer.WriteValue(this.operatorKeyword); + writer.WriteValue(this.checkedKeyword); writer.WriteValue(this.operatorToken); writer.WriteValue(this.parameters); } @@ -29071,17 +29148,23 @@ internal sealed partial class ConversionOperatorMemberCrefSyntax : MemberCrefSyn { internal readonly SyntaxToken implicitOrExplicitKeyword; internal readonly SyntaxToken operatorKeyword; + internal readonly SyntaxToken? checkedKeyword; internal readonly TypeSyntax type; internal readonly CrefParameterListSyntax? parameters; - internal ConversionOperatorMemberCrefSyntax(SyntaxKind kind, SyntaxToken implicitOrExplicitKeyword, SyntaxToken operatorKeyword, TypeSyntax type, CrefParameterListSyntax? parameters, DiagnosticInfo[]? diagnostics, SyntaxAnnotation[]? annotations) + internal ConversionOperatorMemberCrefSyntax(SyntaxKind kind, SyntaxToken implicitOrExplicitKeyword, SyntaxToken operatorKeyword, SyntaxToken? checkedKeyword, TypeSyntax type, CrefParameterListSyntax? parameters, DiagnosticInfo[]? diagnostics, SyntaxAnnotation[]? annotations) : base(kind, diagnostics, annotations) { - this.SlotCount = 4; + this.SlotCount = 5; this.AdjustFlagsAndWidth(implicitOrExplicitKeyword); this.implicitOrExplicitKeyword = implicitOrExplicitKeyword; this.AdjustFlagsAndWidth(operatorKeyword); this.operatorKeyword = operatorKeyword; + if (checkedKeyword != null) + { + this.AdjustFlagsAndWidth(checkedKeyword); + this.checkedKeyword = checkedKeyword; + } this.AdjustFlagsAndWidth(type); this.type = type; if (parameters != null) @@ -29091,15 +29174,20 @@ internal ConversionOperatorMemberCrefSyntax(SyntaxKind kind, SyntaxToken implici } } - internal ConversionOperatorMemberCrefSyntax(SyntaxKind kind, SyntaxToken implicitOrExplicitKeyword, SyntaxToken operatorKeyword, TypeSyntax type, CrefParameterListSyntax? parameters, SyntaxFactoryContext context) + internal ConversionOperatorMemberCrefSyntax(SyntaxKind kind, SyntaxToken implicitOrExplicitKeyword, SyntaxToken operatorKeyword, SyntaxToken? checkedKeyword, TypeSyntax type, CrefParameterListSyntax? parameters, SyntaxFactoryContext context) : base(kind) { this.SetFactoryContext(context); - this.SlotCount = 4; + this.SlotCount = 5; this.AdjustFlagsAndWidth(implicitOrExplicitKeyword); this.implicitOrExplicitKeyword = implicitOrExplicitKeyword; this.AdjustFlagsAndWidth(operatorKeyword); this.operatorKeyword = operatorKeyword; + if (checkedKeyword != null) + { + this.AdjustFlagsAndWidth(checkedKeyword); + this.checkedKeyword = checkedKeyword; + } this.AdjustFlagsAndWidth(type); this.type = type; if (parameters != null) @@ -29109,14 +29197,19 @@ internal ConversionOperatorMemberCrefSyntax(SyntaxKind kind, SyntaxToken implici } } - internal ConversionOperatorMemberCrefSyntax(SyntaxKind kind, SyntaxToken implicitOrExplicitKeyword, SyntaxToken operatorKeyword, TypeSyntax type, CrefParameterListSyntax? parameters) + internal ConversionOperatorMemberCrefSyntax(SyntaxKind kind, SyntaxToken implicitOrExplicitKeyword, SyntaxToken operatorKeyword, SyntaxToken? checkedKeyword, TypeSyntax type, CrefParameterListSyntax? parameters) : base(kind) { - this.SlotCount = 4; + this.SlotCount = 5; this.AdjustFlagsAndWidth(implicitOrExplicitKeyword); this.implicitOrExplicitKeyword = implicitOrExplicitKeyword; this.AdjustFlagsAndWidth(operatorKeyword); this.operatorKeyword = operatorKeyword; + if (checkedKeyword != null) + { + this.AdjustFlagsAndWidth(checkedKeyword); + this.checkedKeyword = checkedKeyword; + } this.AdjustFlagsAndWidth(type); this.type = type; if (parameters != null) @@ -29128,6 +29221,7 @@ internal ConversionOperatorMemberCrefSyntax(SyntaxKind kind, SyntaxToken implici public SyntaxToken ImplicitOrExplicitKeyword => this.implicitOrExplicitKeyword; public SyntaxToken OperatorKeyword => this.operatorKeyword; + public SyntaxToken? CheckedKeyword => this.checkedKeyword; public TypeSyntax Type => this.type; public CrefParameterListSyntax? Parameters => this.parameters; @@ -29136,8 +29230,9 @@ internal ConversionOperatorMemberCrefSyntax(SyntaxKind kind, SyntaxToken implici { 0 => this.implicitOrExplicitKeyword, 1 => this.operatorKeyword, - 2 => this.type, - 3 => this.parameters, + 2 => this.checkedKeyword, + 3 => this.type, + 4 => this.parameters, _ => null, }; @@ -29146,11 +29241,11 @@ internal ConversionOperatorMemberCrefSyntax(SyntaxKind kind, SyntaxToken implici public override void Accept(CSharpSyntaxVisitor visitor) => visitor.VisitConversionOperatorMemberCref(this); public override TResult Accept(CSharpSyntaxVisitor visitor) => visitor.VisitConversionOperatorMemberCref(this); - public ConversionOperatorMemberCrefSyntax Update(SyntaxToken implicitOrExplicitKeyword, SyntaxToken operatorKeyword, TypeSyntax type, CrefParameterListSyntax parameters) + public ConversionOperatorMemberCrefSyntax Update(SyntaxToken implicitOrExplicitKeyword, SyntaxToken operatorKeyword, SyntaxToken checkedKeyword, TypeSyntax type, CrefParameterListSyntax parameters) { - if (implicitOrExplicitKeyword != this.ImplicitOrExplicitKeyword || operatorKeyword != this.OperatorKeyword || type != this.Type || parameters != this.Parameters) + if (implicitOrExplicitKeyword != this.ImplicitOrExplicitKeyword || operatorKeyword != this.OperatorKeyword || checkedKeyword != this.CheckedKeyword || type != this.Type || parameters != this.Parameters) { - var newNode = SyntaxFactory.ConversionOperatorMemberCref(implicitOrExplicitKeyword, operatorKeyword, type, parameters); + var newNode = SyntaxFactory.ConversionOperatorMemberCref(implicitOrExplicitKeyword, operatorKeyword, checkedKeyword, type, parameters); var diags = GetDiagnostics(); if (diags?.Length > 0) newNode = newNode.WithDiagnosticsGreen(diags); @@ -29164,21 +29259,27 @@ public ConversionOperatorMemberCrefSyntax Update(SyntaxToken implicitOrExplicitK } internal override GreenNode SetDiagnostics(DiagnosticInfo[]? diagnostics) - => new ConversionOperatorMemberCrefSyntax(this.Kind, this.implicitOrExplicitKeyword, this.operatorKeyword, this.type, this.parameters, diagnostics, GetAnnotations()); + => new ConversionOperatorMemberCrefSyntax(this.Kind, this.implicitOrExplicitKeyword, this.operatorKeyword, this.checkedKeyword, this.type, this.parameters, diagnostics, GetAnnotations()); internal override GreenNode SetAnnotations(SyntaxAnnotation[]? annotations) - => new ConversionOperatorMemberCrefSyntax(this.Kind, this.implicitOrExplicitKeyword, this.operatorKeyword, this.type, this.parameters, GetDiagnostics(), annotations); + => new ConversionOperatorMemberCrefSyntax(this.Kind, this.implicitOrExplicitKeyword, this.operatorKeyword, this.checkedKeyword, this.type, this.parameters, GetDiagnostics(), annotations); internal ConversionOperatorMemberCrefSyntax(ObjectReader reader) : base(reader) { - this.SlotCount = 4; + this.SlotCount = 5; var implicitOrExplicitKeyword = (SyntaxToken)reader.ReadValue(); AdjustFlagsAndWidth(implicitOrExplicitKeyword); this.implicitOrExplicitKeyword = implicitOrExplicitKeyword; var operatorKeyword = (SyntaxToken)reader.ReadValue(); AdjustFlagsAndWidth(operatorKeyword); this.operatorKeyword = operatorKeyword; + var checkedKeyword = (SyntaxToken?)reader.ReadValue(); + if (checkedKeyword != null) + { + AdjustFlagsAndWidth(checkedKeyword); + this.checkedKeyword = checkedKeyword; + } var type = (TypeSyntax)reader.ReadValue(); AdjustFlagsAndWidth(type); this.type = type; @@ -29195,6 +29296,7 @@ internal override void WriteTo(ObjectWriter writer) base.WriteTo(writer); writer.WriteValue(this.implicitOrExplicitKeyword); writer.WriteValue(this.operatorKeyword); + writer.WriteValue(this.checkedKeyword); writer.WriteValue(this.type); writer.WriteValue(this.parameters); } @@ -35184,10 +35286,10 @@ public override CSharpSyntaxNode VisitMethodDeclaration(MethodDeclarationSyntax => node.Update(VisitList(node.AttributeLists), VisitList(node.Modifiers), (TypeSyntax)Visit(node.ReturnType), (ExplicitInterfaceSpecifierSyntax)Visit(node.ExplicitInterfaceSpecifier), (SyntaxToken)Visit(node.Identifier), (TypeParameterListSyntax)Visit(node.TypeParameterList), (ParameterListSyntax)Visit(node.ParameterList), VisitList(node.ConstraintClauses), (BlockSyntax)Visit(node.Body), (ArrowExpressionClauseSyntax)Visit(node.ExpressionBody), (SyntaxToken)Visit(node.SemicolonToken)); public override CSharpSyntaxNode VisitOperatorDeclaration(OperatorDeclarationSyntax node) - => node.Update(VisitList(node.AttributeLists), VisitList(node.Modifiers), (TypeSyntax)Visit(node.ReturnType), (ExplicitInterfaceSpecifierSyntax)Visit(node.ExplicitInterfaceSpecifier), (SyntaxToken)Visit(node.OperatorKeyword), (SyntaxToken)Visit(node.OperatorToken), (ParameterListSyntax)Visit(node.ParameterList), (BlockSyntax)Visit(node.Body), (ArrowExpressionClauseSyntax)Visit(node.ExpressionBody), (SyntaxToken)Visit(node.SemicolonToken)); + => node.Update(VisitList(node.AttributeLists), VisitList(node.Modifiers), (TypeSyntax)Visit(node.ReturnType), (ExplicitInterfaceSpecifierSyntax)Visit(node.ExplicitInterfaceSpecifier), (SyntaxToken)Visit(node.OperatorKeyword), (SyntaxToken)Visit(node.CheckedKeyword), (SyntaxToken)Visit(node.OperatorToken), (ParameterListSyntax)Visit(node.ParameterList), (BlockSyntax)Visit(node.Body), (ArrowExpressionClauseSyntax)Visit(node.ExpressionBody), (SyntaxToken)Visit(node.SemicolonToken)); public override CSharpSyntaxNode VisitConversionOperatorDeclaration(ConversionOperatorDeclarationSyntax node) - => node.Update(VisitList(node.AttributeLists), VisitList(node.Modifiers), (SyntaxToken)Visit(node.ImplicitOrExplicitKeyword), (ExplicitInterfaceSpecifierSyntax)Visit(node.ExplicitInterfaceSpecifier), (SyntaxToken)Visit(node.OperatorKeyword), (TypeSyntax)Visit(node.Type), (ParameterListSyntax)Visit(node.ParameterList), (BlockSyntax)Visit(node.Body), (ArrowExpressionClauseSyntax)Visit(node.ExpressionBody), (SyntaxToken)Visit(node.SemicolonToken)); + => node.Update(VisitList(node.AttributeLists), VisitList(node.Modifiers), (SyntaxToken)Visit(node.ImplicitOrExplicitKeyword), (ExplicitInterfaceSpecifierSyntax)Visit(node.ExplicitInterfaceSpecifier), (SyntaxToken)Visit(node.OperatorKeyword), (SyntaxToken)Visit(node.CheckedKeyword), (TypeSyntax)Visit(node.Type), (ParameterListSyntax)Visit(node.ParameterList), (BlockSyntax)Visit(node.Body), (ArrowExpressionClauseSyntax)Visit(node.ExpressionBody), (SyntaxToken)Visit(node.SemicolonToken)); public override CSharpSyntaxNode VisitConstructorDeclaration(ConstructorDeclarationSyntax node) => node.Update(VisitList(node.AttributeLists), VisitList(node.Modifiers), (SyntaxToken)Visit(node.Identifier), (ParameterListSyntax)Visit(node.ParameterList), (ConstructorInitializerSyntax)Visit(node.Initializer), (BlockSyntax)Visit(node.Body), (ArrowExpressionClauseSyntax)Visit(node.ExpressionBody), (SyntaxToken)Visit(node.SemicolonToken)); @@ -35250,10 +35352,10 @@ public override CSharpSyntaxNode VisitIndexerMemberCref(IndexerMemberCrefSyntax => node.Update((SyntaxToken)Visit(node.ThisKeyword), (CrefBracketedParameterListSyntax)Visit(node.Parameters)); public override CSharpSyntaxNode VisitOperatorMemberCref(OperatorMemberCrefSyntax node) - => node.Update((SyntaxToken)Visit(node.OperatorKeyword), (SyntaxToken)Visit(node.OperatorToken), (CrefParameterListSyntax)Visit(node.Parameters)); + => node.Update((SyntaxToken)Visit(node.OperatorKeyword), (SyntaxToken)Visit(node.CheckedKeyword), (SyntaxToken)Visit(node.OperatorToken), (CrefParameterListSyntax)Visit(node.Parameters)); public override CSharpSyntaxNode VisitConversionOperatorMemberCref(ConversionOperatorMemberCrefSyntax node) - => node.Update((SyntaxToken)Visit(node.ImplicitOrExplicitKeyword), (SyntaxToken)Visit(node.OperatorKeyword), (TypeSyntax)Visit(node.Type), (CrefParameterListSyntax)Visit(node.Parameters)); + => node.Update((SyntaxToken)Visit(node.ImplicitOrExplicitKeyword), (SyntaxToken)Visit(node.OperatorKeyword), (SyntaxToken)Visit(node.CheckedKeyword), (TypeSyntax)Visit(node.Type), (CrefParameterListSyntax)Visit(node.Parameters)); public override CSharpSyntaxNode VisitCrefParameterList(CrefParameterListSyntax node) => node.Update((SyntaxToken)Visit(node.OpenParenToken), VisitList(node.Parameters), (SyntaxToken)Visit(node.CloseParenToken)); @@ -39133,12 +39235,21 @@ public MethodDeclarationSyntax MethodDeclaration(Microsoft.CodeAnalysis.Syntax.I return new MethodDeclarationSyntax(SyntaxKind.MethodDeclaration, attributeLists.Node, modifiers.Node, returnType, explicitInterfaceSpecifier, identifier, typeParameterList, parameterList, constraintClauses.Node, body, expressionBody, semicolonToken, this.context); } - public OperatorDeclarationSyntax OperatorDeclaration(Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList attributeLists, Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList modifiers, TypeSyntax returnType, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, SyntaxToken operatorToken, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken) + public OperatorDeclarationSyntax OperatorDeclaration(Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList attributeLists, Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList modifiers, TypeSyntax returnType, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, SyntaxToken? checkedKeyword, SyntaxToken operatorToken, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken) { #if DEBUG if (returnType == null) throw new ArgumentNullException(nameof(returnType)); if (operatorKeyword == null) throw new ArgumentNullException(nameof(operatorKeyword)); if (operatorKeyword.Kind != SyntaxKind.OperatorKeyword) throw new ArgumentException(nameof(operatorKeyword)); + if (checkedKeyword != null) + { + switch (checkedKeyword.Kind) + { + case SyntaxKind.CheckedKeyword: + case SyntaxKind.None: break; + default: throw new ArgumentException(nameof(checkedKeyword)); + } + } if (operatorToken == null) throw new ArgumentNullException(nameof(operatorToken)); switch (operatorToken.Kind) { @@ -39179,10 +39290,10 @@ public OperatorDeclarationSyntax OperatorDeclaration(Microsoft.CodeAnalysis.Synt } #endif - return new OperatorDeclarationSyntax(SyntaxKind.OperatorDeclaration, attributeLists.Node, modifiers.Node, returnType, explicitInterfaceSpecifier, operatorKeyword, operatorToken, parameterList, body, expressionBody, semicolonToken, this.context); + return new OperatorDeclarationSyntax(SyntaxKind.OperatorDeclaration, attributeLists.Node, modifiers.Node, returnType, explicitInterfaceSpecifier, operatorKeyword, checkedKeyword, operatorToken, parameterList, body, expressionBody, semicolonToken, this.context); } - public ConversionOperatorDeclarationSyntax ConversionOperatorDeclaration(Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList attributeLists, Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList modifiers, SyntaxToken implicitOrExplicitKeyword, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, TypeSyntax type, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken) + public ConversionOperatorDeclarationSyntax ConversionOperatorDeclaration(Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList attributeLists, Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList modifiers, SyntaxToken implicitOrExplicitKeyword, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, SyntaxToken? checkedKeyword, TypeSyntax type, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken) { #if DEBUG if (implicitOrExplicitKeyword == null) throw new ArgumentNullException(nameof(implicitOrExplicitKeyword)); @@ -39194,6 +39305,15 @@ public ConversionOperatorDeclarationSyntax ConversionOperatorDeclaration(Microso } if (operatorKeyword == null) throw new ArgumentNullException(nameof(operatorKeyword)); if (operatorKeyword.Kind != SyntaxKind.OperatorKeyword) throw new ArgumentException(nameof(operatorKeyword)); + if (checkedKeyword != null) + { + switch (checkedKeyword.Kind) + { + case SyntaxKind.CheckedKeyword: + case SyntaxKind.None: break; + default: throw new ArgumentException(nameof(checkedKeyword)); + } + } if (type == null) throw new ArgumentNullException(nameof(type)); if (parameterList == null) throw new ArgumentNullException(nameof(parameterList)); if (semicolonToken != null) @@ -39207,7 +39327,7 @@ public ConversionOperatorDeclarationSyntax ConversionOperatorDeclaration(Microso } #endif - return new ConversionOperatorDeclarationSyntax(SyntaxKind.ConversionOperatorDeclaration, attributeLists.Node, modifiers.Node, implicitOrExplicitKeyword, explicitInterfaceSpecifier, operatorKeyword, type, parameterList, body, expressionBody, semicolonToken, this.context); + return new ConversionOperatorDeclarationSyntax(SyntaxKind.ConversionOperatorDeclaration, attributeLists.Node, modifiers.Node, implicitOrExplicitKeyword, explicitInterfaceSpecifier, operatorKeyword, checkedKeyword, type, parameterList, body, expressionBody, semicolonToken, this.context); } public ConstructorDeclarationSyntax ConstructorDeclaration(Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList attributeLists, Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList modifiers, SyntaxToken identifier, ParameterListSyntax parameterList, ConstructorInitializerSyntax? initializer, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken) @@ -39629,11 +39749,20 @@ public IndexerMemberCrefSyntax IndexerMemberCref(SyntaxToken thisKeyword, CrefBr return result; } - public OperatorMemberCrefSyntax OperatorMemberCref(SyntaxToken operatorKeyword, SyntaxToken operatorToken, CrefParameterListSyntax? parameters) + public OperatorMemberCrefSyntax OperatorMemberCref(SyntaxToken operatorKeyword, SyntaxToken? checkedKeyword, SyntaxToken operatorToken, CrefParameterListSyntax? parameters) { #if DEBUG if (operatorKeyword == null) throw new ArgumentNullException(nameof(operatorKeyword)); if (operatorKeyword.Kind != SyntaxKind.OperatorKeyword) throw new ArgumentException(nameof(operatorKeyword)); + if (checkedKeyword != null) + { + switch (checkedKeyword.Kind) + { + case SyntaxKind.CheckedKeyword: + case SyntaxKind.None: break; + default: throw new ArgumentException(nameof(checkedKeyword)); + } + } if (operatorToken == null) throw new ArgumentNullException(nameof(operatorToken)); switch (operatorToken.Kind) { @@ -39663,20 +39792,10 @@ public OperatorMemberCrefSyntax OperatorMemberCref(SyntaxToken operatorKeyword, } #endif - int hash; - var cached = CSharpSyntaxNodeCache.TryGetNode((int)SyntaxKind.OperatorMemberCref, operatorKeyword, operatorToken, parameters, this.context, out hash); - if (cached != null) return (OperatorMemberCrefSyntax)cached; - - var result = new OperatorMemberCrefSyntax(SyntaxKind.OperatorMemberCref, operatorKeyword, operatorToken, parameters, this.context); - if (hash >= 0) - { - SyntaxNodeCache.AddNode(result, hash); - } - - return result; + return new OperatorMemberCrefSyntax(SyntaxKind.OperatorMemberCref, operatorKeyword, checkedKeyword, operatorToken, parameters, this.context); } - public ConversionOperatorMemberCrefSyntax ConversionOperatorMemberCref(SyntaxToken implicitOrExplicitKeyword, SyntaxToken operatorKeyword, TypeSyntax type, CrefParameterListSyntax? parameters) + public ConversionOperatorMemberCrefSyntax ConversionOperatorMemberCref(SyntaxToken implicitOrExplicitKeyword, SyntaxToken operatorKeyword, SyntaxToken? checkedKeyword, TypeSyntax type, CrefParameterListSyntax? parameters) { #if DEBUG if (implicitOrExplicitKeyword == null) throw new ArgumentNullException(nameof(implicitOrExplicitKeyword)); @@ -39688,10 +39807,19 @@ public ConversionOperatorMemberCrefSyntax ConversionOperatorMemberCref(SyntaxTok } if (operatorKeyword == null) throw new ArgumentNullException(nameof(operatorKeyword)); if (operatorKeyword.Kind != SyntaxKind.OperatorKeyword) throw new ArgumentException(nameof(operatorKeyword)); + if (checkedKeyword != null) + { + switch (checkedKeyword.Kind) + { + case SyntaxKind.CheckedKeyword: + case SyntaxKind.None: break; + default: throw new ArgumentException(nameof(checkedKeyword)); + } + } if (type == null) throw new ArgumentNullException(nameof(type)); #endif - return new ConversionOperatorMemberCrefSyntax(SyntaxKind.ConversionOperatorMemberCref, implicitOrExplicitKeyword, operatorKeyword, type, parameters, this.context); + return new ConversionOperatorMemberCrefSyntax(SyntaxKind.ConversionOperatorMemberCref, implicitOrExplicitKeyword, operatorKeyword, checkedKeyword, type, parameters, this.context); } public CrefParameterListSyntax CrefParameterList(SyntaxToken openParenToken, Microsoft.CodeAnalysis.Syntax.InternalSyntax.SeparatedSyntaxList parameters, SyntaxToken closeParenToken) @@ -44156,12 +44284,21 @@ public static MethodDeclarationSyntax MethodDeclaration(Microsoft.CodeAnalysis.S return new MethodDeclarationSyntax(SyntaxKind.MethodDeclaration, attributeLists.Node, modifiers.Node, returnType, explicitInterfaceSpecifier, identifier, typeParameterList, parameterList, constraintClauses.Node, body, expressionBody, semicolonToken); } - public static OperatorDeclarationSyntax OperatorDeclaration(Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList attributeLists, Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList modifiers, TypeSyntax returnType, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, SyntaxToken operatorToken, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken) + public static OperatorDeclarationSyntax OperatorDeclaration(Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList attributeLists, Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList modifiers, TypeSyntax returnType, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, SyntaxToken? checkedKeyword, SyntaxToken operatorToken, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken) { #if DEBUG if (returnType == null) throw new ArgumentNullException(nameof(returnType)); if (operatorKeyword == null) throw new ArgumentNullException(nameof(operatorKeyword)); if (operatorKeyword.Kind != SyntaxKind.OperatorKeyword) throw new ArgumentException(nameof(operatorKeyword)); + if (checkedKeyword != null) + { + switch (checkedKeyword.Kind) + { + case SyntaxKind.CheckedKeyword: + case SyntaxKind.None: break; + default: throw new ArgumentException(nameof(checkedKeyword)); + } + } if (operatorToken == null) throw new ArgumentNullException(nameof(operatorToken)); switch (operatorToken.Kind) { @@ -44202,10 +44339,10 @@ public static OperatorDeclarationSyntax OperatorDeclaration(Microsoft.CodeAnalys } #endif - return new OperatorDeclarationSyntax(SyntaxKind.OperatorDeclaration, attributeLists.Node, modifiers.Node, returnType, explicitInterfaceSpecifier, operatorKeyword, operatorToken, parameterList, body, expressionBody, semicolonToken); + return new OperatorDeclarationSyntax(SyntaxKind.OperatorDeclaration, attributeLists.Node, modifiers.Node, returnType, explicitInterfaceSpecifier, operatorKeyword, checkedKeyword, operatorToken, parameterList, body, expressionBody, semicolonToken); } - public static ConversionOperatorDeclarationSyntax ConversionOperatorDeclaration(Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList attributeLists, Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList modifiers, SyntaxToken implicitOrExplicitKeyword, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, TypeSyntax type, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken) + public static ConversionOperatorDeclarationSyntax ConversionOperatorDeclaration(Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList attributeLists, Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList modifiers, SyntaxToken implicitOrExplicitKeyword, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, SyntaxToken? checkedKeyword, TypeSyntax type, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken) { #if DEBUG if (implicitOrExplicitKeyword == null) throw new ArgumentNullException(nameof(implicitOrExplicitKeyword)); @@ -44217,6 +44354,15 @@ public static ConversionOperatorDeclarationSyntax ConversionOperatorDeclaration( } if (operatorKeyword == null) throw new ArgumentNullException(nameof(operatorKeyword)); if (operatorKeyword.Kind != SyntaxKind.OperatorKeyword) throw new ArgumentException(nameof(operatorKeyword)); + if (checkedKeyword != null) + { + switch (checkedKeyword.Kind) + { + case SyntaxKind.CheckedKeyword: + case SyntaxKind.None: break; + default: throw new ArgumentException(nameof(checkedKeyword)); + } + } if (type == null) throw new ArgumentNullException(nameof(type)); if (parameterList == null) throw new ArgumentNullException(nameof(parameterList)); if (semicolonToken != null) @@ -44230,7 +44376,7 @@ public static ConversionOperatorDeclarationSyntax ConversionOperatorDeclaration( } #endif - return new ConversionOperatorDeclarationSyntax(SyntaxKind.ConversionOperatorDeclaration, attributeLists.Node, modifiers.Node, implicitOrExplicitKeyword, explicitInterfaceSpecifier, operatorKeyword, type, parameterList, body, expressionBody, semicolonToken); + return new ConversionOperatorDeclarationSyntax(SyntaxKind.ConversionOperatorDeclaration, attributeLists.Node, modifiers.Node, implicitOrExplicitKeyword, explicitInterfaceSpecifier, operatorKeyword, checkedKeyword, type, parameterList, body, expressionBody, semicolonToken); } public static ConstructorDeclarationSyntax ConstructorDeclaration(Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList attributeLists, Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList modifiers, SyntaxToken identifier, ParameterListSyntax parameterList, ConstructorInitializerSyntax? initializer, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken? semicolonToken) @@ -44652,11 +44798,20 @@ public static IndexerMemberCrefSyntax IndexerMemberCref(SyntaxToken thisKeyword, return result; } - public static OperatorMemberCrefSyntax OperatorMemberCref(SyntaxToken operatorKeyword, SyntaxToken operatorToken, CrefParameterListSyntax? parameters) + public static OperatorMemberCrefSyntax OperatorMemberCref(SyntaxToken operatorKeyword, SyntaxToken? checkedKeyword, SyntaxToken operatorToken, CrefParameterListSyntax? parameters) { #if DEBUG if (operatorKeyword == null) throw new ArgumentNullException(nameof(operatorKeyword)); if (operatorKeyword.Kind != SyntaxKind.OperatorKeyword) throw new ArgumentException(nameof(operatorKeyword)); + if (checkedKeyword != null) + { + switch (checkedKeyword.Kind) + { + case SyntaxKind.CheckedKeyword: + case SyntaxKind.None: break; + default: throw new ArgumentException(nameof(checkedKeyword)); + } + } if (operatorToken == null) throw new ArgumentNullException(nameof(operatorToken)); switch (operatorToken.Kind) { @@ -44686,20 +44841,10 @@ public static OperatorMemberCrefSyntax OperatorMemberCref(SyntaxToken operatorKe } #endif - int hash; - var cached = SyntaxNodeCache.TryGetNode((int)SyntaxKind.OperatorMemberCref, operatorKeyword, operatorToken, parameters, out hash); - if (cached != null) return (OperatorMemberCrefSyntax)cached; - - var result = new OperatorMemberCrefSyntax(SyntaxKind.OperatorMemberCref, operatorKeyword, operatorToken, parameters); - if (hash >= 0) - { - SyntaxNodeCache.AddNode(result, hash); - } - - return result; + return new OperatorMemberCrefSyntax(SyntaxKind.OperatorMemberCref, operatorKeyword, checkedKeyword, operatorToken, parameters); } - public static ConversionOperatorMemberCrefSyntax ConversionOperatorMemberCref(SyntaxToken implicitOrExplicitKeyword, SyntaxToken operatorKeyword, TypeSyntax type, CrefParameterListSyntax? parameters) + public static ConversionOperatorMemberCrefSyntax ConversionOperatorMemberCref(SyntaxToken implicitOrExplicitKeyword, SyntaxToken operatorKeyword, SyntaxToken? checkedKeyword, TypeSyntax type, CrefParameterListSyntax? parameters) { #if DEBUG if (implicitOrExplicitKeyword == null) throw new ArgumentNullException(nameof(implicitOrExplicitKeyword)); @@ -44711,10 +44856,19 @@ public static ConversionOperatorMemberCrefSyntax ConversionOperatorMemberCref(Sy } if (operatorKeyword == null) throw new ArgumentNullException(nameof(operatorKeyword)); if (operatorKeyword.Kind != SyntaxKind.OperatorKeyword) throw new ArgumentException(nameof(operatorKeyword)); + if (checkedKeyword != null) + { + switch (checkedKeyword.Kind) + { + case SyntaxKind.CheckedKeyword: + case SyntaxKind.None: break; + default: throw new ArgumentException(nameof(checkedKeyword)); + } + } if (type == null) throw new ArgumentNullException(nameof(type)); #endif - return new ConversionOperatorMemberCrefSyntax(SyntaxKind.ConversionOperatorMemberCref, implicitOrExplicitKeyword, operatorKeyword, type, parameters); + return new ConversionOperatorMemberCrefSyntax(SyntaxKind.ConversionOperatorMemberCref, implicitOrExplicitKeyword, operatorKeyword, checkedKeyword, type, parameters); } public static CrefParameterListSyntax CrefParameterList(SyntaxToken openParenToken, Microsoft.CodeAnalysis.Syntax.InternalSyntax.SeparatedSyntaxList parameters, SyntaxToken closeParenToken) diff --git a/src/Compilers/CSharp/Portable/Generated/CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Main.Generated.cs b/src/Compilers/CSharp/Portable/Generated/CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Main.Generated.cs index 049bb9a4f6a90..00e18808eaf19 100644 --- a/src/Compilers/CSharp/Portable/Generated/CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Main.Generated.cs +++ b/src/Compilers/CSharp/Portable/Generated/CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Main.Generated.cs @@ -1975,10 +1975,10 @@ public partial class CSharpSyntaxRewriter : CSharpSyntaxVisitor => node.Update(VisitList(node.AttributeLists), VisitList(node.Modifiers), (TypeSyntax?)Visit(node.ReturnType) ?? throw new ArgumentNullException("returnType"), (ExplicitInterfaceSpecifierSyntax?)Visit(node.ExplicitInterfaceSpecifier), VisitToken(node.Identifier), (TypeParameterListSyntax?)Visit(node.TypeParameterList), (ParameterListSyntax?)Visit(node.ParameterList) ?? throw new ArgumentNullException("parameterList"), VisitList(node.ConstraintClauses), (BlockSyntax?)Visit(node.Body), (ArrowExpressionClauseSyntax?)Visit(node.ExpressionBody), VisitToken(node.SemicolonToken)); public override SyntaxNode? VisitOperatorDeclaration(OperatorDeclarationSyntax node) - => node.Update(VisitList(node.AttributeLists), VisitList(node.Modifiers), (TypeSyntax?)Visit(node.ReturnType) ?? throw new ArgumentNullException("returnType"), (ExplicitInterfaceSpecifierSyntax?)Visit(node.ExplicitInterfaceSpecifier), VisitToken(node.OperatorKeyword), VisitToken(node.OperatorToken), (ParameterListSyntax?)Visit(node.ParameterList) ?? throw new ArgumentNullException("parameterList"), (BlockSyntax?)Visit(node.Body), (ArrowExpressionClauseSyntax?)Visit(node.ExpressionBody), VisitToken(node.SemicolonToken)); + => node.Update(VisitList(node.AttributeLists), VisitList(node.Modifiers), (TypeSyntax?)Visit(node.ReturnType) ?? throw new ArgumentNullException("returnType"), (ExplicitInterfaceSpecifierSyntax?)Visit(node.ExplicitInterfaceSpecifier), VisitToken(node.OperatorKeyword), VisitToken(node.CheckedKeyword), VisitToken(node.OperatorToken), (ParameterListSyntax?)Visit(node.ParameterList) ?? throw new ArgumentNullException("parameterList"), (BlockSyntax?)Visit(node.Body), (ArrowExpressionClauseSyntax?)Visit(node.ExpressionBody), VisitToken(node.SemicolonToken)); public override SyntaxNode? VisitConversionOperatorDeclaration(ConversionOperatorDeclarationSyntax node) - => node.Update(VisitList(node.AttributeLists), VisitList(node.Modifiers), VisitToken(node.ImplicitOrExplicitKeyword), (ExplicitInterfaceSpecifierSyntax?)Visit(node.ExplicitInterfaceSpecifier), VisitToken(node.OperatorKeyword), (TypeSyntax?)Visit(node.Type) ?? throw new ArgumentNullException("type"), (ParameterListSyntax?)Visit(node.ParameterList) ?? throw new ArgumentNullException("parameterList"), (BlockSyntax?)Visit(node.Body), (ArrowExpressionClauseSyntax?)Visit(node.ExpressionBody), VisitToken(node.SemicolonToken)); + => node.Update(VisitList(node.AttributeLists), VisitList(node.Modifiers), VisitToken(node.ImplicitOrExplicitKeyword), (ExplicitInterfaceSpecifierSyntax?)Visit(node.ExplicitInterfaceSpecifier), VisitToken(node.OperatorKeyword), VisitToken(node.CheckedKeyword), (TypeSyntax?)Visit(node.Type) ?? throw new ArgumentNullException("type"), (ParameterListSyntax?)Visit(node.ParameterList) ?? throw new ArgumentNullException("parameterList"), (BlockSyntax?)Visit(node.Body), (ArrowExpressionClauseSyntax?)Visit(node.ExpressionBody), VisitToken(node.SemicolonToken)); public override SyntaxNode? VisitConstructorDeclaration(ConstructorDeclarationSyntax node) => node.Update(VisitList(node.AttributeLists), VisitList(node.Modifiers), VisitToken(node.Identifier), (ParameterListSyntax?)Visit(node.ParameterList) ?? throw new ArgumentNullException("parameterList"), (ConstructorInitializerSyntax?)Visit(node.Initializer), (BlockSyntax?)Visit(node.Body), (ArrowExpressionClauseSyntax?)Visit(node.ExpressionBody), VisitToken(node.SemicolonToken)); @@ -2041,10 +2041,10 @@ public partial class CSharpSyntaxRewriter : CSharpSyntaxVisitor => node.Update(VisitToken(node.ThisKeyword), (CrefBracketedParameterListSyntax?)Visit(node.Parameters)); public override SyntaxNode? VisitOperatorMemberCref(OperatorMemberCrefSyntax node) - => node.Update(VisitToken(node.OperatorKeyword), VisitToken(node.OperatorToken), (CrefParameterListSyntax?)Visit(node.Parameters)); + => node.Update(VisitToken(node.OperatorKeyword), VisitToken(node.CheckedKeyword), VisitToken(node.OperatorToken), (CrefParameterListSyntax?)Visit(node.Parameters)); public override SyntaxNode? VisitConversionOperatorMemberCref(ConversionOperatorMemberCrefSyntax node) - => node.Update(VisitToken(node.ImplicitOrExplicitKeyword), VisitToken(node.OperatorKeyword), (TypeSyntax?)Visit(node.Type) ?? throw new ArgumentNullException("type"), (CrefParameterListSyntax?)Visit(node.Parameters)); + => node.Update(VisitToken(node.ImplicitOrExplicitKeyword), VisitToken(node.OperatorKeyword), VisitToken(node.CheckedKeyword), (TypeSyntax?)Visit(node.Type) ?? throw new ArgumentNullException("type"), (CrefParameterListSyntax?)Visit(node.Parameters)); public override SyntaxNode? VisitCrefParameterList(CrefParameterListSyntax node) => node.Update(VisitToken(node.OpenParenToken), VisitList(node.Parameters), VisitToken(node.CloseParenToken)); @@ -5206,10 +5206,16 @@ public static MethodDeclarationSyntax MethodDeclaration(TypeSyntax returnType, s => SyntaxFactory.MethodDeclaration(default, default(SyntaxTokenList), returnType, default, SyntaxFactory.Identifier(identifier), default, SyntaxFactory.ParameterList(), default, default, default, default); /// Creates a new OperatorDeclarationSyntax instance. - public static OperatorDeclarationSyntax OperatorDeclaration(SyntaxList attributeLists, SyntaxTokenList modifiers, TypeSyntax returnType, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, SyntaxToken operatorToken, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken semicolonToken) + public static OperatorDeclarationSyntax OperatorDeclaration(SyntaxList attributeLists, SyntaxTokenList modifiers, TypeSyntax returnType, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, SyntaxToken checkedKeyword, SyntaxToken operatorToken, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken semicolonToken) { if (returnType == null) throw new ArgumentNullException(nameof(returnType)); if (operatorKeyword.Kind() != SyntaxKind.OperatorKeyword) throw new ArgumentException(nameof(operatorKeyword)); + switch (checkedKeyword.Kind()) + { + case SyntaxKind.CheckedKeyword: + case SyntaxKind.None: break; + default: throw new ArgumentException(nameof(checkedKeyword)); + } switch (operatorToken.Kind()) { case SyntaxKind.PlusToken: @@ -5244,19 +5250,19 @@ public static OperatorDeclarationSyntax OperatorDeclaration(SyntaxList(), modifiers.Node.ToGreenList(), (Syntax.InternalSyntax.TypeSyntax)returnType.Green, explicitInterfaceSpecifier == null ? null : (Syntax.InternalSyntax.ExplicitInterfaceSpecifierSyntax)explicitInterfaceSpecifier.Green, (Syntax.InternalSyntax.SyntaxToken)operatorKeyword.Node!, (Syntax.InternalSyntax.SyntaxToken)operatorToken.Node!, (Syntax.InternalSyntax.ParameterListSyntax)parameterList.Green, body == null ? null : (Syntax.InternalSyntax.BlockSyntax)body.Green, expressionBody == null ? null : (Syntax.InternalSyntax.ArrowExpressionClauseSyntax)expressionBody.Green, (Syntax.InternalSyntax.SyntaxToken?)semicolonToken.Node).CreateRed(); + return (OperatorDeclarationSyntax)Syntax.InternalSyntax.SyntaxFactory.OperatorDeclaration(attributeLists.Node.ToGreenList(), modifiers.Node.ToGreenList(), (Syntax.InternalSyntax.TypeSyntax)returnType.Green, explicitInterfaceSpecifier == null ? null : (Syntax.InternalSyntax.ExplicitInterfaceSpecifierSyntax)explicitInterfaceSpecifier.Green, (Syntax.InternalSyntax.SyntaxToken)operatorKeyword.Node!, (Syntax.InternalSyntax.SyntaxToken?)checkedKeyword.Node, (Syntax.InternalSyntax.SyntaxToken)operatorToken.Node!, (Syntax.InternalSyntax.ParameterListSyntax)parameterList.Green, body == null ? null : (Syntax.InternalSyntax.BlockSyntax)body.Green, expressionBody == null ? null : (Syntax.InternalSyntax.ArrowExpressionClauseSyntax)expressionBody.Green, (Syntax.InternalSyntax.SyntaxToken?)semicolonToken.Node).CreateRed(); } /// Creates a new OperatorDeclarationSyntax instance. public static OperatorDeclarationSyntax OperatorDeclaration(SyntaxList attributeLists, SyntaxTokenList modifiers, TypeSyntax returnType, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorToken, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody) - => SyntaxFactory.OperatorDeclaration(attributeLists, modifiers, returnType, explicitInterfaceSpecifier, SyntaxFactory.Token(SyntaxKind.OperatorKeyword), operatorToken, parameterList, body, expressionBody, default); + => SyntaxFactory.OperatorDeclaration(attributeLists, modifiers, returnType, explicitInterfaceSpecifier, SyntaxFactory.Token(SyntaxKind.OperatorKeyword), default, operatorToken, parameterList, body, expressionBody, default); /// Creates a new OperatorDeclarationSyntax instance. public static OperatorDeclarationSyntax OperatorDeclaration(TypeSyntax returnType, SyntaxToken operatorToken) - => SyntaxFactory.OperatorDeclaration(default, default(SyntaxTokenList), returnType, default, SyntaxFactory.Token(SyntaxKind.OperatorKeyword), operatorToken, SyntaxFactory.ParameterList(), default, default, default); + => SyntaxFactory.OperatorDeclaration(default, default(SyntaxTokenList), returnType, default, SyntaxFactory.Token(SyntaxKind.OperatorKeyword), default, operatorToken, SyntaxFactory.ParameterList(), default, default, default); /// Creates a new ConversionOperatorDeclarationSyntax instance. - public static ConversionOperatorDeclarationSyntax ConversionOperatorDeclaration(SyntaxList attributeLists, SyntaxTokenList modifiers, SyntaxToken implicitOrExplicitKeyword, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, TypeSyntax type, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken semicolonToken) + public static ConversionOperatorDeclarationSyntax ConversionOperatorDeclaration(SyntaxList attributeLists, SyntaxTokenList modifiers, SyntaxToken implicitOrExplicitKeyword, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, SyntaxToken checkedKeyword, TypeSyntax type, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken semicolonToken) { switch (implicitOrExplicitKeyword.Kind()) { @@ -5265,6 +5271,12 @@ public static ConversionOperatorDeclarationSyntax ConversionOperatorDeclaration( default: throw new ArgumentException(nameof(implicitOrExplicitKeyword)); } if (operatorKeyword.Kind() != SyntaxKind.OperatorKeyword) throw new ArgumentException(nameof(operatorKeyword)); + switch (checkedKeyword.Kind()) + { + case SyntaxKind.CheckedKeyword: + case SyntaxKind.None: break; + default: throw new ArgumentException(nameof(checkedKeyword)); + } if (type == null) throw new ArgumentNullException(nameof(type)); if (parameterList == null) throw new ArgumentNullException(nameof(parameterList)); switch (semicolonToken.Kind()) @@ -5273,16 +5285,16 @@ public static ConversionOperatorDeclarationSyntax ConversionOperatorDeclaration( case SyntaxKind.None: break; default: throw new ArgumentException(nameof(semicolonToken)); } - return (ConversionOperatorDeclarationSyntax)Syntax.InternalSyntax.SyntaxFactory.ConversionOperatorDeclaration(attributeLists.Node.ToGreenList(), modifiers.Node.ToGreenList(), (Syntax.InternalSyntax.SyntaxToken)implicitOrExplicitKeyword.Node!, explicitInterfaceSpecifier == null ? null : (Syntax.InternalSyntax.ExplicitInterfaceSpecifierSyntax)explicitInterfaceSpecifier.Green, (Syntax.InternalSyntax.SyntaxToken)operatorKeyword.Node!, (Syntax.InternalSyntax.TypeSyntax)type.Green, (Syntax.InternalSyntax.ParameterListSyntax)parameterList.Green, body == null ? null : (Syntax.InternalSyntax.BlockSyntax)body.Green, expressionBody == null ? null : (Syntax.InternalSyntax.ArrowExpressionClauseSyntax)expressionBody.Green, (Syntax.InternalSyntax.SyntaxToken?)semicolonToken.Node).CreateRed(); + return (ConversionOperatorDeclarationSyntax)Syntax.InternalSyntax.SyntaxFactory.ConversionOperatorDeclaration(attributeLists.Node.ToGreenList(), modifiers.Node.ToGreenList(), (Syntax.InternalSyntax.SyntaxToken)implicitOrExplicitKeyword.Node!, explicitInterfaceSpecifier == null ? null : (Syntax.InternalSyntax.ExplicitInterfaceSpecifierSyntax)explicitInterfaceSpecifier.Green, (Syntax.InternalSyntax.SyntaxToken)operatorKeyword.Node!, (Syntax.InternalSyntax.SyntaxToken?)checkedKeyword.Node, (Syntax.InternalSyntax.TypeSyntax)type.Green, (Syntax.InternalSyntax.ParameterListSyntax)parameterList.Green, body == null ? null : (Syntax.InternalSyntax.BlockSyntax)body.Green, expressionBody == null ? null : (Syntax.InternalSyntax.ArrowExpressionClauseSyntax)expressionBody.Green, (Syntax.InternalSyntax.SyntaxToken?)semicolonToken.Node).CreateRed(); } /// Creates a new ConversionOperatorDeclarationSyntax instance. public static ConversionOperatorDeclarationSyntax ConversionOperatorDeclaration(SyntaxList attributeLists, SyntaxTokenList modifiers, SyntaxToken implicitOrExplicitKeyword, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, TypeSyntax type, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody) - => SyntaxFactory.ConversionOperatorDeclaration(attributeLists, modifiers, implicitOrExplicitKeyword, explicitInterfaceSpecifier, SyntaxFactory.Token(SyntaxKind.OperatorKeyword), type, parameterList, body, expressionBody, default); + => SyntaxFactory.ConversionOperatorDeclaration(attributeLists, modifiers, implicitOrExplicitKeyword, explicitInterfaceSpecifier, SyntaxFactory.Token(SyntaxKind.OperatorKeyword), default, type, parameterList, body, expressionBody, default); /// Creates a new ConversionOperatorDeclarationSyntax instance. public static ConversionOperatorDeclarationSyntax ConversionOperatorDeclaration(SyntaxToken implicitOrExplicitKeyword, TypeSyntax type) - => SyntaxFactory.ConversionOperatorDeclaration(default, default(SyntaxTokenList), implicitOrExplicitKeyword, default, SyntaxFactory.Token(SyntaxKind.OperatorKeyword), type, SyntaxFactory.ParameterList(), default, default, default); + => SyntaxFactory.ConversionOperatorDeclaration(default, default(SyntaxTokenList), implicitOrExplicitKeyword, default, SyntaxFactory.Token(SyntaxKind.OperatorKeyword), default, type, SyntaxFactory.ParameterList(), default, default, default); /// Creates a new ConstructorDeclarationSyntax instance. public static ConstructorDeclarationSyntax ConstructorDeclaration(SyntaxList attributeLists, SyntaxTokenList modifiers, SyntaxToken identifier, ParameterListSyntax parameterList, ConstructorInitializerSyntax? initializer, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken semicolonToken) @@ -5664,9 +5676,15 @@ public static IndexerMemberCrefSyntax IndexerMemberCref(CrefBracketedParameterLi => SyntaxFactory.IndexerMemberCref(SyntaxFactory.Token(SyntaxKind.ThisKeyword), parameters); /// Creates a new OperatorMemberCrefSyntax instance. - public static OperatorMemberCrefSyntax OperatorMemberCref(SyntaxToken operatorKeyword, SyntaxToken operatorToken, CrefParameterListSyntax? parameters) + public static OperatorMemberCrefSyntax OperatorMemberCref(SyntaxToken operatorKeyword, SyntaxToken checkedKeyword, SyntaxToken operatorToken, CrefParameterListSyntax? parameters) { if (operatorKeyword.Kind() != SyntaxKind.OperatorKeyword) throw new ArgumentException(nameof(operatorKeyword)); + switch (checkedKeyword.Kind()) + { + case SyntaxKind.CheckedKeyword: + case SyntaxKind.None: break; + default: throw new ArgumentException(nameof(checkedKeyword)); + } switch (operatorToken.Kind()) { case SyntaxKind.PlusToken: @@ -5693,19 +5711,19 @@ public static OperatorMemberCrefSyntax OperatorMemberCref(SyntaxToken operatorKe case SyntaxKind.TrueKeyword: break; default: throw new ArgumentException(nameof(operatorToken)); } - return (OperatorMemberCrefSyntax)Syntax.InternalSyntax.SyntaxFactory.OperatorMemberCref((Syntax.InternalSyntax.SyntaxToken)operatorKeyword.Node!, (Syntax.InternalSyntax.SyntaxToken)operatorToken.Node!, parameters == null ? null : (Syntax.InternalSyntax.CrefParameterListSyntax)parameters.Green).CreateRed(); + return (OperatorMemberCrefSyntax)Syntax.InternalSyntax.SyntaxFactory.OperatorMemberCref((Syntax.InternalSyntax.SyntaxToken)operatorKeyword.Node!, (Syntax.InternalSyntax.SyntaxToken?)checkedKeyword.Node, (Syntax.InternalSyntax.SyntaxToken)operatorToken.Node!, parameters == null ? null : (Syntax.InternalSyntax.CrefParameterListSyntax)parameters.Green).CreateRed(); } /// Creates a new OperatorMemberCrefSyntax instance. public static OperatorMemberCrefSyntax OperatorMemberCref(SyntaxToken operatorToken, CrefParameterListSyntax? parameters) - => SyntaxFactory.OperatorMemberCref(SyntaxFactory.Token(SyntaxKind.OperatorKeyword), operatorToken, parameters); + => SyntaxFactory.OperatorMemberCref(SyntaxFactory.Token(SyntaxKind.OperatorKeyword), default, operatorToken, parameters); /// Creates a new OperatorMemberCrefSyntax instance. public static OperatorMemberCrefSyntax OperatorMemberCref(SyntaxToken operatorToken) - => SyntaxFactory.OperatorMemberCref(SyntaxFactory.Token(SyntaxKind.OperatorKeyword), operatorToken, default); + => SyntaxFactory.OperatorMemberCref(SyntaxFactory.Token(SyntaxKind.OperatorKeyword), default, operatorToken, default); /// Creates a new ConversionOperatorMemberCrefSyntax instance. - public static ConversionOperatorMemberCrefSyntax ConversionOperatorMemberCref(SyntaxToken implicitOrExplicitKeyword, SyntaxToken operatorKeyword, TypeSyntax type, CrefParameterListSyntax? parameters) + public static ConversionOperatorMemberCrefSyntax ConversionOperatorMemberCref(SyntaxToken implicitOrExplicitKeyword, SyntaxToken operatorKeyword, SyntaxToken checkedKeyword, TypeSyntax type, CrefParameterListSyntax? parameters) { switch (implicitOrExplicitKeyword.Kind()) { @@ -5714,17 +5732,23 @@ public static ConversionOperatorMemberCrefSyntax ConversionOperatorMemberCref(Sy default: throw new ArgumentException(nameof(implicitOrExplicitKeyword)); } if (operatorKeyword.Kind() != SyntaxKind.OperatorKeyword) throw new ArgumentException(nameof(operatorKeyword)); + switch (checkedKeyword.Kind()) + { + case SyntaxKind.CheckedKeyword: + case SyntaxKind.None: break; + default: throw new ArgumentException(nameof(checkedKeyword)); + } if (type == null) throw new ArgumentNullException(nameof(type)); - return (ConversionOperatorMemberCrefSyntax)Syntax.InternalSyntax.SyntaxFactory.ConversionOperatorMemberCref((Syntax.InternalSyntax.SyntaxToken)implicitOrExplicitKeyword.Node!, (Syntax.InternalSyntax.SyntaxToken)operatorKeyword.Node!, (Syntax.InternalSyntax.TypeSyntax)type.Green, parameters == null ? null : (Syntax.InternalSyntax.CrefParameterListSyntax)parameters.Green).CreateRed(); + return (ConversionOperatorMemberCrefSyntax)Syntax.InternalSyntax.SyntaxFactory.ConversionOperatorMemberCref((Syntax.InternalSyntax.SyntaxToken)implicitOrExplicitKeyword.Node!, (Syntax.InternalSyntax.SyntaxToken)operatorKeyword.Node!, (Syntax.InternalSyntax.SyntaxToken?)checkedKeyword.Node, (Syntax.InternalSyntax.TypeSyntax)type.Green, parameters == null ? null : (Syntax.InternalSyntax.CrefParameterListSyntax)parameters.Green).CreateRed(); } /// Creates a new ConversionOperatorMemberCrefSyntax instance. public static ConversionOperatorMemberCrefSyntax ConversionOperatorMemberCref(SyntaxToken implicitOrExplicitKeyword, TypeSyntax type, CrefParameterListSyntax? parameters) - => SyntaxFactory.ConversionOperatorMemberCref(implicitOrExplicitKeyword, SyntaxFactory.Token(SyntaxKind.OperatorKeyword), type, parameters); + => SyntaxFactory.ConversionOperatorMemberCref(implicitOrExplicitKeyword, SyntaxFactory.Token(SyntaxKind.OperatorKeyword), default, type, parameters); /// Creates a new ConversionOperatorMemberCrefSyntax instance. public static ConversionOperatorMemberCrefSyntax ConversionOperatorMemberCref(SyntaxToken implicitOrExplicitKeyword, TypeSyntax type) - => SyntaxFactory.ConversionOperatorMemberCref(implicitOrExplicitKeyword, SyntaxFactory.Token(SyntaxKind.OperatorKeyword), type, default); + => SyntaxFactory.ConversionOperatorMemberCref(implicitOrExplicitKeyword, SyntaxFactory.Token(SyntaxKind.OperatorKeyword), default, type, default); /// Creates a new CrefParameterListSyntax instance. public static CrefParameterListSyntax CrefParameterList(SyntaxToken openParenToken, SeparatedSyntaxList parameters, SyntaxToken closeParenToken) diff --git a/src/Compilers/CSharp/Portable/Generated/CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Syntax.Generated.cs b/src/Compilers/CSharp/Portable/Generated/CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Syntax.Generated.cs index da5214e1246b6..54f678e874108 100644 --- a/src/Compilers/CSharp/Portable/Generated/CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Syntax.Generated.cs +++ b/src/Compilers/CSharp/Portable/Generated/CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Syntax.Generated.cs @@ -11860,14 +11860,24 @@ public override SyntaxTokenList Modifiers /// Gets the "operator" keyword. public SyntaxToken OperatorKeyword => new SyntaxToken(this, ((Syntax.InternalSyntax.OperatorDeclarationSyntax)this.Green).operatorKeyword, GetChildPosition(4), GetChildIndex(4)); + /// Gets the "checked" keyword. + public SyntaxToken CheckedKeyword + { + get + { + var slot = ((Syntax.InternalSyntax.OperatorDeclarationSyntax)this.Green).checkedKeyword; + return slot != null ? new SyntaxToken(this, slot, GetChildPosition(5), GetChildIndex(5)) : default; + } + } + /// Gets the operator token. - public SyntaxToken OperatorToken => new SyntaxToken(this, ((Syntax.InternalSyntax.OperatorDeclarationSyntax)this.Green).operatorToken, GetChildPosition(5), GetChildIndex(5)); + public SyntaxToken OperatorToken => new SyntaxToken(this, ((Syntax.InternalSyntax.OperatorDeclarationSyntax)this.Green).operatorToken, GetChildPosition(6), GetChildIndex(6)); - public override ParameterListSyntax ParameterList => GetRed(ref this.parameterList, 6)!; + public override ParameterListSyntax ParameterList => GetRed(ref this.parameterList, 7)!; - public override BlockSyntax? Body => GetRed(ref this.body, 7); + public override BlockSyntax? Body => GetRed(ref this.body, 8); - public override ArrowExpressionClauseSyntax? ExpressionBody => GetRed(ref this.expressionBody, 8); + public override ArrowExpressionClauseSyntax? ExpressionBody => GetRed(ref this.expressionBody, 9); /// Gets the optional semicolon token. public override SyntaxToken SemicolonToken @@ -11875,7 +11885,7 @@ public override SyntaxToken SemicolonToken get { var slot = ((Syntax.InternalSyntax.OperatorDeclarationSyntax)this.Green).semicolonToken; - return slot != null ? new SyntaxToken(this, slot, GetChildPosition(9), GetChildIndex(9)) : default; + return slot != null ? new SyntaxToken(this, slot, GetChildPosition(10), GetChildIndex(10)) : default; } } @@ -11885,9 +11895,9 @@ public override SyntaxToken SemicolonToken 0 => GetRedAtZero(ref this.attributeLists)!, 2 => GetRed(ref this.returnType, 2)!, 3 => GetRed(ref this.explicitInterfaceSpecifier, 3), - 6 => GetRed(ref this.parameterList, 6)!, - 7 => GetRed(ref this.body, 7), - 8 => GetRed(ref this.expressionBody, 8), + 7 => GetRed(ref this.parameterList, 7)!, + 8 => GetRed(ref this.body, 8), + 9 => GetRed(ref this.expressionBody, 9), _ => null, }; @@ -11897,20 +11907,20 @@ public override SyntaxToken SemicolonToken 0 => this.attributeLists, 2 => this.returnType, 3 => this.explicitInterfaceSpecifier, - 6 => this.parameterList, - 7 => this.body, - 8 => this.expressionBody, + 7 => this.parameterList, + 8 => this.body, + 9 => this.expressionBody, _ => null, }; public override void Accept(CSharpSyntaxVisitor visitor) => visitor.VisitOperatorDeclaration(this); public override TResult? Accept(CSharpSyntaxVisitor visitor) where TResult : default => visitor.VisitOperatorDeclaration(this); - public OperatorDeclarationSyntax Update(SyntaxList attributeLists, SyntaxTokenList modifiers, TypeSyntax returnType, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, SyntaxToken operatorToken, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken semicolonToken) + public OperatorDeclarationSyntax Update(SyntaxList attributeLists, SyntaxTokenList modifiers, TypeSyntax returnType, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, SyntaxToken checkedKeyword, SyntaxToken operatorToken, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken semicolonToken) { - if (attributeLists != this.AttributeLists || modifiers != this.Modifiers || returnType != this.ReturnType || explicitInterfaceSpecifier != this.ExplicitInterfaceSpecifier || operatorKeyword != this.OperatorKeyword || operatorToken != this.OperatorToken || parameterList != this.ParameterList || body != this.Body || expressionBody != this.ExpressionBody || semicolonToken != this.SemicolonToken) + if (attributeLists != this.AttributeLists || modifiers != this.Modifiers || returnType != this.ReturnType || explicitInterfaceSpecifier != this.ExplicitInterfaceSpecifier || operatorKeyword != this.OperatorKeyword || checkedKeyword != this.CheckedKeyword || operatorToken != this.OperatorToken || parameterList != this.ParameterList || body != this.Body || expressionBody != this.ExpressionBody || semicolonToken != this.SemicolonToken) { - var newNode = SyntaxFactory.OperatorDeclaration(attributeLists, modifiers, returnType, explicitInterfaceSpecifier, operatorKeyword, operatorToken, parameterList, body, expressionBody, semicolonToken); + var newNode = SyntaxFactory.OperatorDeclaration(attributeLists, modifiers, returnType, explicitInterfaceSpecifier, operatorKeyword, checkedKeyword, operatorToken, parameterList, body, expressionBody, semicolonToken); var annotations = GetAnnotations(); return annotations?.Length > 0 ? newNode.WithAnnotations(annotations) : newNode; } @@ -11919,21 +11929,22 @@ public OperatorDeclarationSyntax Update(SyntaxList attribut } internal override MemberDeclarationSyntax WithAttributeListsCore(SyntaxList attributeLists) => WithAttributeLists(attributeLists); - public new OperatorDeclarationSyntax WithAttributeLists(SyntaxList attributeLists) => Update(attributeLists, this.Modifiers, this.ReturnType, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.OperatorToken, this.ParameterList, this.Body, this.ExpressionBody, this.SemicolonToken); + public new OperatorDeclarationSyntax WithAttributeLists(SyntaxList attributeLists) => Update(attributeLists, this.Modifiers, this.ReturnType, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.CheckedKeyword, this.OperatorToken, this.ParameterList, this.Body, this.ExpressionBody, this.SemicolonToken); internal override MemberDeclarationSyntax WithModifiersCore(SyntaxTokenList modifiers) => WithModifiers(modifiers); - public new OperatorDeclarationSyntax WithModifiers(SyntaxTokenList modifiers) => Update(this.AttributeLists, modifiers, this.ReturnType, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.OperatorToken, this.ParameterList, this.Body, this.ExpressionBody, this.SemicolonToken); - public OperatorDeclarationSyntax WithReturnType(TypeSyntax returnType) => Update(this.AttributeLists, this.Modifiers, returnType, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.OperatorToken, this.ParameterList, this.Body, this.ExpressionBody, this.SemicolonToken); - public OperatorDeclarationSyntax WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, explicitInterfaceSpecifier, this.OperatorKeyword, this.OperatorToken, this.ParameterList, this.Body, this.ExpressionBody, this.SemicolonToken); - public OperatorDeclarationSyntax WithOperatorKeyword(SyntaxToken operatorKeyword) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, this.ExplicitInterfaceSpecifier, operatorKeyword, this.OperatorToken, this.ParameterList, this.Body, this.ExpressionBody, this.SemicolonToken); - public OperatorDeclarationSyntax WithOperatorToken(SyntaxToken operatorToken) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, operatorToken, this.ParameterList, this.Body, this.ExpressionBody, this.SemicolonToken); + public new OperatorDeclarationSyntax WithModifiers(SyntaxTokenList modifiers) => Update(this.AttributeLists, modifiers, this.ReturnType, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.CheckedKeyword, this.OperatorToken, this.ParameterList, this.Body, this.ExpressionBody, this.SemicolonToken); + public OperatorDeclarationSyntax WithReturnType(TypeSyntax returnType) => Update(this.AttributeLists, this.Modifiers, returnType, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.CheckedKeyword, this.OperatorToken, this.ParameterList, this.Body, this.ExpressionBody, this.SemicolonToken); + public OperatorDeclarationSyntax WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, explicitInterfaceSpecifier, this.OperatorKeyword, this.CheckedKeyword, this.OperatorToken, this.ParameterList, this.Body, this.ExpressionBody, this.SemicolonToken); + public OperatorDeclarationSyntax WithOperatorKeyword(SyntaxToken operatorKeyword) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, this.ExplicitInterfaceSpecifier, operatorKeyword, this.CheckedKeyword, this.OperatorToken, this.ParameterList, this.Body, this.ExpressionBody, this.SemicolonToken); + public OperatorDeclarationSyntax WithCheckedKeyword(SyntaxToken checkedKeyword) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, checkedKeyword, this.OperatorToken, this.ParameterList, this.Body, this.ExpressionBody, this.SemicolonToken); + public OperatorDeclarationSyntax WithOperatorToken(SyntaxToken operatorToken) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.CheckedKeyword, operatorToken, this.ParameterList, this.Body, this.ExpressionBody, this.SemicolonToken); internal override BaseMethodDeclarationSyntax WithParameterListCore(ParameterListSyntax parameterList) => WithParameterList(parameterList); - public new OperatorDeclarationSyntax WithParameterList(ParameterListSyntax parameterList) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.OperatorToken, parameterList, this.Body, this.ExpressionBody, this.SemicolonToken); + public new OperatorDeclarationSyntax WithParameterList(ParameterListSyntax parameterList) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.CheckedKeyword, this.OperatorToken, parameterList, this.Body, this.ExpressionBody, this.SemicolonToken); internal override BaseMethodDeclarationSyntax WithBodyCore(BlockSyntax? body) => WithBody(body); - public new OperatorDeclarationSyntax WithBody(BlockSyntax? body) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.OperatorToken, this.ParameterList, body, this.ExpressionBody, this.SemicolonToken); + public new OperatorDeclarationSyntax WithBody(BlockSyntax? body) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.CheckedKeyword, this.OperatorToken, this.ParameterList, body, this.ExpressionBody, this.SemicolonToken); internal override BaseMethodDeclarationSyntax WithExpressionBodyCore(ArrowExpressionClauseSyntax? expressionBody) => WithExpressionBody(expressionBody); - public new OperatorDeclarationSyntax WithExpressionBody(ArrowExpressionClauseSyntax? expressionBody) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.OperatorToken, this.ParameterList, this.Body, expressionBody, this.SemicolonToken); + public new OperatorDeclarationSyntax WithExpressionBody(ArrowExpressionClauseSyntax? expressionBody) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.CheckedKeyword, this.OperatorToken, this.ParameterList, this.Body, expressionBody, this.SemicolonToken); internal override BaseMethodDeclarationSyntax WithSemicolonTokenCore(SyntaxToken semicolonToken) => WithSemicolonToken(semicolonToken); - public new OperatorDeclarationSyntax WithSemicolonToken(SyntaxToken semicolonToken) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.OperatorToken, this.ParameterList, this.Body, this.ExpressionBody, semicolonToken); + public new OperatorDeclarationSyntax WithSemicolonToken(SyntaxToken semicolonToken) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.CheckedKeyword, this.OperatorToken, this.ParameterList, this.Body, this.ExpressionBody, semicolonToken); internal override MemberDeclarationSyntax AddAttributeListsCore(params AttributeListSyntax[] items) => AddAttributeLists(items); public new OperatorDeclarationSyntax AddAttributeLists(params AttributeListSyntax[] items) => WithAttributeLists(this.AttributeLists.AddRange(items)); @@ -11995,14 +12006,24 @@ public override SyntaxTokenList Modifiers /// Gets the "operator" token. public SyntaxToken OperatorKeyword => new SyntaxToken(this, ((Syntax.InternalSyntax.ConversionOperatorDeclarationSyntax)this.Green).operatorKeyword, GetChildPosition(4), GetChildIndex(4)); + /// Gets the "checked" keyword. + public SyntaxToken CheckedKeyword + { + get + { + var slot = ((Syntax.InternalSyntax.ConversionOperatorDeclarationSyntax)this.Green).checkedKeyword; + return slot != null ? new SyntaxToken(this, slot, GetChildPosition(5), GetChildIndex(5)) : default; + } + } + /// Gets the type. - public TypeSyntax Type => GetRed(ref this.type, 5)!; + public TypeSyntax Type => GetRed(ref this.type, 6)!; - public override ParameterListSyntax ParameterList => GetRed(ref this.parameterList, 6)!; + public override ParameterListSyntax ParameterList => GetRed(ref this.parameterList, 7)!; - public override BlockSyntax? Body => GetRed(ref this.body, 7); + public override BlockSyntax? Body => GetRed(ref this.body, 8); - public override ArrowExpressionClauseSyntax? ExpressionBody => GetRed(ref this.expressionBody, 8); + public override ArrowExpressionClauseSyntax? ExpressionBody => GetRed(ref this.expressionBody, 9); /// Gets the optional semicolon token. public override SyntaxToken SemicolonToken @@ -12010,7 +12031,7 @@ public override SyntaxToken SemicolonToken get { var slot = ((Syntax.InternalSyntax.ConversionOperatorDeclarationSyntax)this.Green).semicolonToken; - return slot != null ? new SyntaxToken(this, slot, GetChildPosition(9), GetChildIndex(9)) : default; + return slot != null ? new SyntaxToken(this, slot, GetChildPosition(10), GetChildIndex(10)) : default; } } @@ -12019,10 +12040,10 @@ public override SyntaxToken SemicolonToken { 0 => GetRedAtZero(ref this.attributeLists)!, 3 => GetRed(ref this.explicitInterfaceSpecifier, 3), - 5 => GetRed(ref this.type, 5)!, - 6 => GetRed(ref this.parameterList, 6)!, - 7 => GetRed(ref this.body, 7), - 8 => GetRed(ref this.expressionBody, 8), + 6 => GetRed(ref this.type, 6)!, + 7 => GetRed(ref this.parameterList, 7)!, + 8 => GetRed(ref this.body, 8), + 9 => GetRed(ref this.expressionBody, 9), _ => null, }; @@ -12031,21 +12052,21 @@ public override SyntaxToken SemicolonToken { 0 => this.attributeLists, 3 => this.explicitInterfaceSpecifier, - 5 => this.type, - 6 => this.parameterList, - 7 => this.body, - 8 => this.expressionBody, + 6 => this.type, + 7 => this.parameterList, + 8 => this.body, + 9 => this.expressionBody, _ => null, }; public override void Accept(CSharpSyntaxVisitor visitor) => visitor.VisitConversionOperatorDeclaration(this); public override TResult? Accept(CSharpSyntaxVisitor visitor) where TResult : default => visitor.VisitConversionOperatorDeclaration(this); - public ConversionOperatorDeclarationSyntax Update(SyntaxList attributeLists, SyntaxTokenList modifiers, SyntaxToken implicitOrExplicitKeyword, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, TypeSyntax type, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken semicolonToken) + public ConversionOperatorDeclarationSyntax Update(SyntaxList attributeLists, SyntaxTokenList modifiers, SyntaxToken implicitOrExplicitKeyword, ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, SyntaxToken operatorKeyword, SyntaxToken checkedKeyword, TypeSyntax type, ParameterListSyntax parameterList, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken semicolonToken) { - if (attributeLists != this.AttributeLists || modifiers != this.Modifiers || implicitOrExplicitKeyword != this.ImplicitOrExplicitKeyword || explicitInterfaceSpecifier != this.ExplicitInterfaceSpecifier || operatorKeyword != this.OperatorKeyword || type != this.Type || parameterList != this.ParameterList || body != this.Body || expressionBody != this.ExpressionBody || semicolonToken != this.SemicolonToken) + if (attributeLists != this.AttributeLists || modifiers != this.Modifiers || implicitOrExplicitKeyword != this.ImplicitOrExplicitKeyword || explicitInterfaceSpecifier != this.ExplicitInterfaceSpecifier || operatorKeyword != this.OperatorKeyword || checkedKeyword != this.CheckedKeyword || type != this.Type || parameterList != this.ParameterList || body != this.Body || expressionBody != this.ExpressionBody || semicolonToken != this.SemicolonToken) { - var newNode = SyntaxFactory.ConversionOperatorDeclaration(attributeLists, modifiers, implicitOrExplicitKeyword, explicitInterfaceSpecifier, operatorKeyword, type, parameterList, body, expressionBody, semicolonToken); + var newNode = SyntaxFactory.ConversionOperatorDeclaration(attributeLists, modifiers, implicitOrExplicitKeyword, explicitInterfaceSpecifier, operatorKeyword, checkedKeyword, type, parameterList, body, expressionBody, semicolonToken); var annotations = GetAnnotations(); return annotations?.Length > 0 ? newNode.WithAnnotations(annotations) : newNode; } @@ -12054,21 +12075,22 @@ public ConversionOperatorDeclarationSyntax Update(SyntaxList attributeLists) => WithAttributeLists(attributeLists); - public new ConversionOperatorDeclarationSyntax WithAttributeLists(SyntaxList attributeLists) => Update(attributeLists, this.Modifiers, this.ImplicitOrExplicitKeyword, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.Type, this.ParameterList, this.Body, this.ExpressionBody, this.SemicolonToken); + public new ConversionOperatorDeclarationSyntax WithAttributeLists(SyntaxList attributeLists) => Update(attributeLists, this.Modifiers, this.ImplicitOrExplicitKeyword, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.CheckedKeyword, this.Type, this.ParameterList, this.Body, this.ExpressionBody, this.SemicolonToken); internal override MemberDeclarationSyntax WithModifiersCore(SyntaxTokenList modifiers) => WithModifiers(modifiers); - public new ConversionOperatorDeclarationSyntax WithModifiers(SyntaxTokenList modifiers) => Update(this.AttributeLists, modifiers, this.ImplicitOrExplicitKeyword, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.Type, this.ParameterList, this.Body, this.ExpressionBody, this.SemicolonToken); - public ConversionOperatorDeclarationSyntax WithImplicitOrExplicitKeyword(SyntaxToken implicitOrExplicitKeyword) => Update(this.AttributeLists, this.Modifiers, implicitOrExplicitKeyword, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.Type, this.ParameterList, this.Body, this.ExpressionBody, this.SemicolonToken); - public ConversionOperatorDeclarationSyntax WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier) => Update(this.AttributeLists, this.Modifiers, this.ImplicitOrExplicitKeyword, explicitInterfaceSpecifier, this.OperatorKeyword, this.Type, this.ParameterList, this.Body, this.ExpressionBody, this.SemicolonToken); - public ConversionOperatorDeclarationSyntax WithOperatorKeyword(SyntaxToken operatorKeyword) => Update(this.AttributeLists, this.Modifiers, this.ImplicitOrExplicitKeyword, this.ExplicitInterfaceSpecifier, operatorKeyword, this.Type, this.ParameterList, this.Body, this.ExpressionBody, this.SemicolonToken); - public ConversionOperatorDeclarationSyntax WithType(TypeSyntax type) => Update(this.AttributeLists, this.Modifiers, this.ImplicitOrExplicitKeyword, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, type, this.ParameterList, this.Body, this.ExpressionBody, this.SemicolonToken); + public new ConversionOperatorDeclarationSyntax WithModifiers(SyntaxTokenList modifiers) => Update(this.AttributeLists, modifiers, this.ImplicitOrExplicitKeyword, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.CheckedKeyword, this.Type, this.ParameterList, this.Body, this.ExpressionBody, this.SemicolonToken); + public ConversionOperatorDeclarationSyntax WithImplicitOrExplicitKeyword(SyntaxToken implicitOrExplicitKeyword) => Update(this.AttributeLists, this.Modifiers, implicitOrExplicitKeyword, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.CheckedKeyword, this.Type, this.ParameterList, this.Body, this.ExpressionBody, this.SemicolonToken); + public ConversionOperatorDeclarationSyntax WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier) => Update(this.AttributeLists, this.Modifiers, this.ImplicitOrExplicitKeyword, explicitInterfaceSpecifier, this.OperatorKeyword, this.CheckedKeyword, this.Type, this.ParameterList, this.Body, this.ExpressionBody, this.SemicolonToken); + public ConversionOperatorDeclarationSyntax WithOperatorKeyword(SyntaxToken operatorKeyword) => Update(this.AttributeLists, this.Modifiers, this.ImplicitOrExplicitKeyword, this.ExplicitInterfaceSpecifier, operatorKeyword, this.CheckedKeyword, this.Type, this.ParameterList, this.Body, this.ExpressionBody, this.SemicolonToken); + public ConversionOperatorDeclarationSyntax WithCheckedKeyword(SyntaxToken checkedKeyword) => Update(this.AttributeLists, this.Modifiers, this.ImplicitOrExplicitKeyword, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, checkedKeyword, this.Type, this.ParameterList, this.Body, this.ExpressionBody, this.SemicolonToken); + public ConversionOperatorDeclarationSyntax WithType(TypeSyntax type) => Update(this.AttributeLists, this.Modifiers, this.ImplicitOrExplicitKeyword, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.CheckedKeyword, type, this.ParameterList, this.Body, this.ExpressionBody, this.SemicolonToken); internal override BaseMethodDeclarationSyntax WithParameterListCore(ParameterListSyntax parameterList) => WithParameterList(parameterList); - public new ConversionOperatorDeclarationSyntax WithParameterList(ParameterListSyntax parameterList) => Update(this.AttributeLists, this.Modifiers, this.ImplicitOrExplicitKeyword, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.Type, parameterList, this.Body, this.ExpressionBody, this.SemicolonToken); + public new ConversionOperatorDeclarationSyntax WithParameterList(ParameterListSyntax parameterList) => Update(this.AttributeLists, this.Modifiers, this.ImplicitOrExplicitKeyword, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.CheckedKeyword, this.Type, parameterList, this.Body, this.ExpressionBody, this.SemicolonToken); internal override BaseMethodDeclarationSyntax WithBodyCore(BlockSyntax? body) => WithBody(body); - public new ConversionOperatorDeclarationSyntax WithBody(BlockSyntax? body) => Update(this.AttributeLists, this.Modifiers, this.ImplicitOrExplicitKeyword, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.Type, this.ParameterList, body, this.ExpressionBody, this.SemicolonToken); + public new ConversionOperatorDeclarationSyntax WithBody(BlockSyntax? body) => Update(this.AttributeLists, this.Modifiers, this.ImplicitOrExplicitKeyword, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.CheckedKeyword, this.Type, this.ParameterList, body, this.ExpressionBody, this.SemicolonToken); internal override BaseMethodDeclarationSyntax WithExpressionBodyCore(ArrowExpressionClauseSyntax? expressionBody) => WithExpressionBody(expressionBody); - public new ConversionOperatorDeclarationSyntax WithExpressionBody(ArrowExpressionClauseSyntax? expressionBody) => Update(this.AttributeLists, this.Modifiers, this.ImplicitOrExplicitKeyword, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.Type, this.ParameterList, this.Body, expressionBody, this.SemicolonToken); + public new ConversionOperatorDeclarationSyntax WithExpressionBody(ArrowExpressionClauseSyntax? expressionBody) => Update(this.AttributeLists, this.Modifiers, this.ImplicitOrExplicitKeyword, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.CheckedKeyword, this.Type, this.ParameterList, this.Body, expressionBody, this.SemicolonToken); internal override BaseMethodDeclarationSyntax WithSemicolonTokenCore(SyntaxToken semicolonToken) => WithSemicolonToken(semicolonToken); - public new ConversionOperatorDeclarationSyntax WithSemicolonToken(SyntaxToken semicolonToken) => Update(this.AttributeLists, this.Modifiers, this.ImplicitOrExplicitKeyword, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.Type, this.ParameterList, this.Body, this.ExpressionBody, semicolonToken); + public new ConversionOperatorDeclarationSyntax WithSemicolonToken(SyntaxToken semicolonToken) => Update(this.AttributeLists, this.Modifiers, this.ImplicitOrExplicitKeyword, this.ExplicitInterfaceSpecifier, this.OperatorKeyword, this.CheckedKeyword, this.Type, this.ParameterList, this.Body, this.ExpressionBody, semicolonToken); internal override MemberDeclarationSyntax AddAttributeListsCore(params AttributeListSyntax[] items) => AddAttributeLists(items); public new ConversionOperatorDeclarationSyntax AddAttributeLists(params AttributeListSyntax[] items) => WithAttributeLists(this.AttributeLists.AddRange(items)); @@ -13746,23 +13768,32 @@ internal OperatorMemberCrefSyntax(InternalSyntax.CSharpSyntaxNode green, SyntaxN public SyntaxToken OperatorKeyword => new SyntaxToken(this, ((Syntax.InternalSyntax.OperatorMemberCrefSyntax)this.Green).operatorKeyword, Position, 0); + public SyntaxToken CheckedKeyword + { + get + { + var slot = ((Syntax.InternalSyntax.OperatorMemberCrefSyntax)this.Green).checkedKeyword; + return slot != null ? new SyntaxToken(this, slot, GetChildPosition(1), GetChildIndex(1)) : default; + } + } + /// Gets the operator token. - public SyntaxToken OperatorToken => new SyntaxToken(this, ((Syntax.InternalSyntax.OperatorMemberCrefSyntax)this.Green).operatorToken, GetChildPosition(1), GetChildIndex(1)); + public SyntaxToken OperatorToken => new SyntaxToken(this, ((Syntax.InternalSyntax.OperatorMemberCrefSyntax)this.Green).operatorToken, GetChildPosition(2), GetChildIndex(2)); - public CrefParameterListSyntax? Parameters => GetRed(ref this.parameters, 2); + public CrefParameterListSyntax? Parameters => GetRed(ref this.parameters, 3); - internal override SyntaxNode? GetNodeSlot(int index) => index == 2 ? GetRed(ref this.parameters, 2) : null; + internal override SyntaxNode? GetNodeSlot(int index) => index == 3 ? GetRed(ref this.parameters, 3) : null; - internal override SyntaxNode? GetCachedSlot(int index) => index == 2 ? this.parameters : null; + internal override SyntaxNode? GetCachedSlot(int index) => index == 3 ? this.parameters : null; public override void Accept(CSharpSyntaxVisitor visitor) => visitor.VisitOperatorMemberCref(this); public override TResult? Accept(CSharpSyntaxVisitor visitor) where TResult : default => visitor.VisitOperatorMemberCref(this); - public OperatorMemberCrefSyntax Update(SyntaxToken operatorKeyword, SyntaxToken operatorToken, CrefParameterListSyntax? parameters) + public OperatorMemberCrefSyntax Update(SyntaxToken operatorKeyword, SyntaxToken checkedKeyword, SyntaxToken operatorToken, CrefParameterListSyntax? parameters) { - if (operatorKeyword != this.OperatorKeyword || operatorToken != this.OperatorToken || parameters != this.Parameters) + if (operatorKeyword != this.OperatorKeyword || checkedKeyword != this.CheckedKeyword || operatorToken != this.OperatorToken || parameters != this.Parameters) { - var newNode = SyntaxFactory.OperatorMemberCref(operatorKeyword, operatorToken, parameters); + var newNode = SyntaxFactory.OperatorMemberCref(operatorKeyword, checkedKeyword, operatorToken, parameters); var annotations = GetAnnotations(); return annotations?.Length > 0 ? newNode.WithAnnotations(annotations) : newNode; } @@ -13770,9 +13801,10 @@ public OperatorMemberCrefSyntax Update(SyntaxToken operatorKeyword, SyntaxToken return this; } - public OperatorMemberCrefSyntax WithOperatorKeyword(SyntaxToken operatorKeyword) => Update(operatorKeyword, this.OperatorToken, this.Parameters); - public OperatorMemberCrefSyntax WithOperatorToken(SyntaxToken operatorToken) => Update(this.OperatorKeyword, operatorToken, this.Parameters); - public OperatorMemberCrefSyntax WithParameters(CrefParameterListSyntax? parameters) => Update(this.OperatorKeyword, this.OperatorToken, parameters); + public OperatorMemberCrefSyntax WithOperatorKeyword(SyntaxToken operatorKeyword) => Update(operatorKeyword, this.CheckedKeyword, this.OperatorToken, this.Parameters); + public OperatorMemberCrefSyntax WithCheckedKeyword(SyntaxToken checkedKeyword) => Update(this.OperatorKeyword, checkedKeyword, this.OperatorToken, this.Parameters); + public OperatorMemberCrefSyntax WithOperatorToken(SyntaxToken operatorToken) => Update(this.OperatorKeyword, this.CheckedKeyword, operatorToken, this.Parameters); + public OperatorMemberCrefSyntax WithParameters(CrefParameterListSyntax? parameters) => Update(this.OperatorKeyword, this.CheckedKeyword, this.OperatorToken, parameters); public OperatorMemberCrefSyntax AddParametersParameters(params CrefParameterSyntax[] items) { @@ -13805,34 +13837,43 @@ internal ConversionOperatorMemberCrefSyntax(InternalSyntax.CSharpSyntaxNode gree public SyntaxToken OperatorKeyword => new SyntaxToken(this, ((Syntax.InternalSyntax.ConversionOperatorMemberCrefSyntax)this.Green).operatorKeyword, GetChildPosition(1), GetChildIndex(1)); - public TypeSyntax Type => GetRed(ref this.type, 2)!; + public SyntaxToken CheckedKeyword + { + get + { + var slot = ((Syntax.InternalSyntax.ConversionOperatorMemberCrefSyntax)this.Green).checkedKeyword; + return slot != null ? new SyntaxToken(this, slot, GetChildPosition(2), GetChildIndex(2)) : default; + } + } - public CrefParameterListSyntax? Parameters => GetRed(ref this.parameters, 3); + public TypeSyntax Type => GetRed(ref this.type, 3)!; + + public CrefParameterListSyntax? Parameters => GetRed(ref this.parameters, 4); internal override SyntaxNode? GetNodeSlot(int index) => index switch { - 2 => GetRed(ref this.type, 2)!, - 3 => GetRed(ref this.parameters, 3), + 3 => GetRed(ref this.type, 3)!, + 4 => GetRed(ref this.parameters, 4), _ => null, }; internal override SyntaxNode? GetCachedSlot(int index) => index switch { - 2 => this.type, - 3 => this.parameters, + 3 => this.type, + 4 => this.parameters, _ => null, }; public override void Accept(CSharpSyntaxVisitor visitor) => visitor.VisitConversionOperatorMemberCref(this); public override TResult? Accept(CSharpSyntaxVisitor visitor) where TResult : default => visitor.VisitConversionOperatorMemberCref(this); - public ConversionOperatorMemberCrefSyntax Update(SyntaxToken implicitOrExplicitKeyword, SyntaxToken operatorKeyword, TypeSyntax type, CrefParameterListSyntax? parameters) + public ConversionOperatorMemberCrefSyntax Update(SyntaxToken implicitOrExplicitKeyword, SyntaxToken operatorKeyword, SyntaxToken checkedKeyword, TypeSyntax type, CrefParameterListSyntax? parameters) { - if (implicitOrExplicitKeyword != this.ImplicitOrExplicitKeyword || operatorKeyword != this.OperatorKeyword || type != this.Type || parameters != this.Parameters) + if (implicitOrExplicitKeyword != this.ImplicitOrExplicitKeyword || operatorKeyword != this.OperatorKeyword || checkedKeyword != this.CheckedKeyword || type != this.Type || parameters != this.Parameters) { - var newNode = SyntaxFactory.ConversionOperatorMemberCref(implicitOrExplicitKeyword, operatorKeyword, type, parameters); + var newNode = SyntaxFactory.ConversionOperatorMemberCref(implicitOrExplicitKeyword, operatorKeyword, checkedKeyword, type, parameters); var annotations = GetAnnotations(); return annotations?.Length > 0 ? newNode.WithAnnotations(annotations) : newNode; } @@ -13840,10 +13881,11 @@ public ConversionOperatorMemberCrefSyntax Update(SyntaxToken implicitOrExplicitK return this; } - public ConversionOperatorMemberCrefSyntax WithImplicitOrExplicitKeyword(SyntaxToken implicitOrExplicitKeyword) => Update(implicitOrExplicitKeyword, this.OperatorKeyword, this.Type, this.Parameters); - public ConversionOperatorMemberCrefSyntax WithOperatorKeyword(SyntaxToken operatorKeyword) => Update(this.ImplicitOrExplicitKeyword, operatorKeyword, this.Type, this.Parameters); - public ConversionOperatorMemberCrefSyntax WithType(TypeSyntax type) => Update(this.ImplicitOrExplicitKeyword, this.OperatorKeyword, type, this.Parameters); - public ConversionOperatorMemberCrefSyntax WithParameters(CrefParameterListSyntax? parameters) => Update(this.ImplicitOrExplicitKeyword, this.OperatorKeyword, this.Type, parameters); + public ConversionOperatorMemberCrefSyntax WithImplicitOrExplicitKeyword(SyntaxToken implicitOrExplicitKeyword) => Update(implicitOrExplicitKeyword, this.OperatorKeyword, this.CheckedKeyword, this.Type, this.Parameters); + public ConversionOperatorMemberCrefSyntax WithOperatorKeyword(SyntaxToken operatorKeyword) => Update(this.ImplicitOrExplicitKeyword, operatorKeyword, this.CheckedKeyword, this.Type, this.Parameters); + public ConversionOperatorMemberCrefSyntax WithCheckedKeyword(SyntaxToken checkedKeyword) => Update(this.ImplicitOrExplicitKeyword, this.OperatorKeyword, checkedKeyword, this.Type, this.Parameters); + public ConversionOperatorMemberCrefSyntax WithType(TypeSyntax type) => Update(this.ImplicitOrExplicitKeyword, this.OperatorKeyword, this.CheckedKeyword, type, this.Parameters); + public ConversionOperatorMemberCrefSyntax WithParameters(CrefParameterListSyntax? parameters) => Update(this.ImplicitOrExplicitKeyword, this.OperatorKeyword, this.CheckedKeyword, this.Type, parameters); public ConversionOperatorMemberCrefSyntax AddParametersParameters(params CrefParameterSyntax[] items) { diff --git a/src/Compilers/CSharp/Portable/Parser/DocumentationCommentParser.cs b/src/Compilers/CSharp/Portable/Parser/DocumentationCommentParser.cs index 1b4e3afda53a8..fd4d6a3bd883c 100644 --- a/src/Compilers/CSharp/Portable/Parser/DocumentationCommentParser.cs +++ b/src/Compilers/CSharp/Portable/Parser/DocumentationCommentParser.cs @@ -988,6 +988,7 @@ private OperatorMemberCrefSyntax ParseOperatorMemberCref() { Debug.Assert(CurrentToken.Kind == SyntaxKind.OperatorKeyword); SyntaxToken operatorKeyword = EatToken(); + SyntaxToken checkedKeyword = TryEatToken(SyntaxKind.CheckedKeyword); // PROTOTYPE(CheckedUserDefinedOperators) : consider gracefully recovering from erroneous use of 'unchecked' at this location SyntaxToken operatorToken; @@ -1067,7 +1068,7 @@ private OperatorMemberCrefSyntax ParseOperatorMemberCref() CrefParameterListSyntax parameters = ParseCrefParameterList(); - return SyntaxFactory.OperatorMemberCref(operatorKeyword, operatorToken, parameters); + return SyntaxFactory.OperatorMemberCref(operatorKeyword, checkedKeyword, operatorToken, parameters); } /// @@ -1080,12 +1081,13 @@ private ConversionOperatorMemberCrefSyntax ParseConversionOperatorMemberCref() SyntaxToken implicitOrExplicit = EatToken(); SyntaxToken operatorKeyword = EatToken(SyntaxKind.OperatorKeyword); + SyntaxToken checkedKeyword = TryEatToken(SyntaxKind.CheckedKeyword); // PROTOTYPE(CheckedUserDefinedOperators) : consider gracefully recovering from erroneous use of 'unchecked' at this location TypeSyntax type = ParseCrefType(typeArgumentsMustBeIdentifiers: false); CrefParameterListSyntax parameters = ParseCrefParameterList(); - return SyntaxFactory.ConversionOperatorMemberCref(implicitOrExplicit, operatorKeyword, type, parameters); + return SyntaxFactory.ConversionOperatorMemberCref(implicitOrExplicit, operatorKeyword, checkedKeyword, type, parameters); } /// diff --git a/src/Compilers/CSharp/Portable/Parser/LanguageParser.cs b/src/Compilers/CSharp/Portable/Parser/LanguageParser.cs index d0a0ac11e529c..19f22e20575dd 100644 --- a/src/Compilers/CSharp/Portable/Parser/LanguageParser.cs +++ b/src/Compilers/CSharp/Portable/Parser/LanguageParser.cs @@ -3305,8 +3305,23 @@ private ConversionOperatorDeclarationSyntax TryParseConversionOperatorDeclaratio if (style.IsMissing) { - if (this.CurrentToken.Kind != SyntaxKind.OperatorKeyword || SyntaxFacts.IsAnyOverloadableOperator(this.PeekToken(1).Kind) || + bool possibleConversion; + + if (this.CurrentToken.Kind != SyntaxKind.OperatorKeyword || explicitInterfaceOpt?.DotToken.IsMissing == true) + { + possibleConversion = false; + } + else if (this.PeekToken(1).Kind == SyntaxKind.CheckedKeyword) // PROTOTYPE(CheckedUserDefinedOperators) : consider gracefully recovering from erroneous use of 'unchecked' at this location + { + possibleConversion = !SyntaxFacts.IsAnyOverloadableOperator(this.PeekToken(2).Kind); + } + else + { + possibleConversion = !SyntaxFacts.IsAnyOverloadableOperator(this.PeekToken(1).Kind); + } + + if (!possibleConversion) { this.Reset(ref point); return null; @@ -3332,6 +3347,7 @@ private ConversionOperatorDeclarationSyntax TryParseConversionOperatorDeclaratio style, explicitInterfaceOpt, opKeyword, + checkedKeyword: null, type, paramList, body: null, @@ -3340,6 +3356,7 @@ private ConversionOperatorDeclarationSyntax TryParseConversionOperatorDeclaratio } opKeyword = this.EatToken(SyntaxKind.OperatorKeyword); + var checkedKeyword = this.TryEatToken(SyntaxKind.CheckedKeyword); // PROTOTYPE(CheckedUserDefinedOperators) : consider gracefully recovering from erroneous use of 'unchecked' at this location this.Release(ref point); point = GetResetPoint(); @@ -3369,6 +3386,7 @@ private ConversionOperatorDeclarationSyntax TryParseConversionOperatorDeclaratio style, explicitInterfaceOpt, opKeyword, + checkedKeyword, type, paramList, blockBody, @@ -3463,6 +3481,7 @@ private OperatorDeclarationSyntax ParseOperatorDeclaration( ExplicitInterfaceSpecifierSyntax explicitInterfaceOpt) { var opKeyword = this.EatToken(SyntaxKind.OperatorKeyword); + var checkedKeyword = this.TryEatToken(SyntaxKind.CheckedKeyword); // PROTOTYPE(CheckedUserDefinedOperators) : consider gracefully recovering from erroneous use of 'unchecked' at this location SyntaxToken opToken; int opTokenErrorOffset; int opTokenErrorWidth; @@ -3582,6 +3601,7 @@ private OperatorDeclarationSyntax ParseOperatorDeclaration( type, explicitInterfaceOpt, opKeyword, + checkedKeyword, opToken, paramList, blockBody, diff --git a/src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt b/src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt index d367804586e73..ec21a85cbe291 100644 --- a/src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt +++ b/src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt @@ -28,3 +28,20 @@ static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.TryStatement(Microsoft.CodeAn static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.TryStatement(Microsoft.CodeAnalysis.SyntaxToken tryKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.BlockSyntax! block, Microsoft.CodeAnalysis.SyntaxList catches, Microsoft.CodeAnalysis.CSharp.Syntax.FinallyClauseSyntax? finally) -> Microsoft.CodeAnalysis.CSharp.Syntax.TryStatementSyntax! *REMOVED*static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.TryStatement(Microsoft.CodeAnalysis.SyntaxToken tryKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.BlockSyntax! block, Microsoft.CodeAnalysis.SyntaxList catches, Microsoft.CodeAnalysis.CSharp.Syntax.FinallyClauseSyntax! finally) -> Microsoft.CodeAnalysis.CSharp.Syntax.TryStatementSyntax! static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.InterpolatedStringExpression(Microsoft.CodeAnalysis.SyntaxToken stringStartToken, Microsoft.CodeAnalysis.SyntaxToken stringEndToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.InterpolatedStringExpressionSyntax! + +Microsoft.CodeAnalysis.CSharp.Syntax.ConversionOperatorDeclarationSyntax.CheckedKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken +Microsoft.CodeAnalysis.CSharp.Syntax.ConversionOperatorDeclarationSyntax.Update(Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.SyntaxToken implicitOrExplicitKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, Microsoft.CodeAnalysis.SyntaxToken operatorKeyword, Microsoft.CodeAnalysis.SyntaxToken checkedKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax! type, Microsoft.CodeAnalysis.CSharp.Syntax.ParameterListSyntax! parameterList, Microsoft.CodeAnalysis.CSharp.Syntax.BlockSyntax? body, Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax? expressionBody, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.ConversionOperatorDeclarationSyntax! +Microsoft.CodeAnalysis.CSharp.Syntax.ConversionOperatorDeclarationSyntax.WithCheckedKeyword(Microsoft.CodeAnalysis.SyntaxToken checkedKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.ConversionOperatorDeclarationSyntax! +Microsoft.CodeAnalysis.CSharp.Syntax.ConversionOperatorMemberCrefSyntax.CheckedKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken +Microsoft.CodeAnalysis.CSharp.Syntax.ConversionOperatorMemberCrefSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken implicitOrExplicitKeyword, Microsoft.CodeAnalysis.SyntaxToken operatorKeyword, Microsoft.CodeAnalysis.SyntaxToken checkedKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax! type, Microsoft.CodeAnalysis.CSharp.Syntax.CrefParameterListSyntax? parameters) -> Microsoft.CodeAnalysis.CSharp.Syntax.ConversionOperatorMemberCrefSyntax! +Microsoft.CodeAnalysis.CSharp.Syntax.ConversionOperatorMemberCrefSyntax.WithCheckedKeyword(Microsoft.CodeAnalysis.SyntaxToken checkedKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.ConversionOperatorMemberCrefSyntax! +Microsoft.CodeAnalysis.CSharp.Syntax.OperatorDeclarationSyntax.CheckedKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken +Microsoft.CodeAnalysis.CSharp.Syntax.OperatorDeclarationSyntax.Update(Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax! returnType, Microsoft.CodeAnalysis.CSharp.Syntax.ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, Microsoft.CodeAnalysis.SyntaxToken operatorKeyword, Microsoft.CodeAnalysis.SyntaxToken checkedKeyword, Microsoft.CodeAnalysis.SyntaxToken operatorToken, Microsoft.CodeAnalysis.CSharp.Syntax.ParameterListSyntax! parameterList, Microsoft.CodeAnalysis.CSharp.Syntax.BlockSyntax? body, Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax? expressionBody, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.OperatorDeclarationSyntax! +Microsoft.CodeAnalysis.CSharp.Syntax.OperatorDeclarationSyntax.WithCheckedKeyword(Microsoft.CodeAnalysis.SyntaxToken checkedKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.OperatorDeclarationSyntax! +Microsoft.CodeAnalysis.CSharp.Syntax.OperatorMemberCrefSyntax.CheckedKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken +Microsoft.CodeAnalysis.CSharp.Syntax.OperatorMemberCrefSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken operatorKeyword, Microsoft.CodeAnalysis.SyntaxToken checkedKeyword, Microsoft.CodeAnalysis.SyntaxToken operatorToken, Microsoft.CodeAnalysis.CSharp.Syntax.CrefParameterListSyntax? parameters) -> Microsoft.CodeAnalysis.CSharp.Syntax.OperatorMemberCrefSyntax! +Microsoft.CodeAnalysis.CSharp.Syntax.OperatorMemberCrefSyntax.WithCheckedKeyword(Microsoft.CodeAnalysis.SyntaxToken checkedKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.OperatorMemberCrefSyntax! +static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.OperatorDeclaration(Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax! returnType, Microsoft.CodeAnalysis.CSharp.Syntax.ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, Microsoft.CodeAnalysis.SyntaxToken operatorKeyword, Microsoft.CodeAnalysis.SyntaxToken checkedKeyword, Microsoft.CodeAnalysis.SyntaxToken operatorToken, Microsoft.CodeAnalysis.CSharp.Syntax.ParameterListSyntax! parameterList, Microsoft.CodeAnalysis.CSharp.Syntax.BlockSyntax? body, Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax? expressionBody, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.OperatorDeclarationSyntax! +static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ConversionOperatorDeclaration(Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.SyntaxToken implicitOrExplicitKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, Microsoft.CodeAnalysis.SyntaxToken operatorKeyword, Microsoft.CodeAnalysis.SyntaxToken checkedKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax! type, Microsoft.CodeAnalysis.CSharp.Syntax.ParameterListSyntax! parameterList, Microsoft.CodeAnalysis.CSharp.Syntax.BlockSyntax? body, Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax? expressionBody, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.ConversionOperatorDeclarationSyntax! +static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.OperatorMemberCref(Microsoft.CodeAnalysis.SyntaxToken operatorKeyword, Microsoft.CodeAnalysis.SyntaxToken checkedKeyword, Microsoft.CodeAnalysis.SyntaxToken operatorToken, Microsoft.CodeAnalysis.CSharp.Syntax.CrefParameterListSyntax? parameters) -> Microsoft.CodeAnalysis.CSharp.Syntax.OperatorMemberCrefSyntax! +static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ConversionOperatorMemberCref(Microsoft.CodeAnalysis.SyntaxToken implicitOrExplicitKeyword, Microsoft.CodeAnalysis.SyntaxToken operatorKeyword, Microsoft.CodeAnalysis.SyntaxToken checkedKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax! type, Microsoft.CodeAnalysis.CSharp.Syntax.CrefParameterListSyntax? parameters) -> Microsoft.CodeAnalysis.CSharp.Syntax.ConversionOperatorMemberCrefSyntax! \ No newline at end of file diff --git a/src/Compilers/CSharp/Portable/Syntax/ConversionOperatorDeclarationSyntax.cs b/src/Compilers/CSharp/Portable/Syntax/ConversionOperatorDeclarationSyntax.cs index a59184c90ac57..8fc38ab40d705 100644 --- a/src/Compilers/CSharp/Portable/Syntax/ConversionOperatorDeclarationSyntax.cs +++ b/src/Compilers/CSharp/Portable/Syntax/ConversionOperatorDeclarationSyntax.cs @@ -29,5 +29,31 @@ public ConversionOperatorDeclarationSyntax Update( expressionBody: expressionBody, semicolonToken: semicolonToken); } + + public ConversionOperatorDeclarationSyntax Update( + SyntaxList attributeLists, + SyntaxTokenList modifiers, + SyntaxToken implicitOrExplicitKeyword, + ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, + SyntaxToken operatorKeyword, + TypeSyntax type, + ParameterListSyntax parameterList, + BlockSyntax? body, + ArrowExpressionClauseSyntax? expressionBody, + SyntaxToken semicolonToken) + { + return Update( + attributeLists: attributeLists, + modifiers: modifiers, + implicitOrExplicitKeyword: implicitOrExplicitKeyword, + explicitInterfaceSpecifier: explicitInterfaceSpecifier, + operatorKeyword: operatorKeyword, + checkedKeyword: this.CheckedKeyword, + type: type, + parameterList: parameterList, + body: body, + expressionBody: expressionBody, + semicolonToken: semicolonToken); + } } } diff --git a/src/Compilers/CSharp/Portable/Syntax/ConversionOperatorMemberCrefSyntax.cs b/src/Compilers/CSharp/Portable/Syntax/ConversionOperatorMemberCrefSyntax.cs new file mode 100644 index 0000000000000..ea6574cb39a18 --- /dev/null +++ b/src/Compilers/CSharp/Portable/Syntax/ConversionOperatorMemberCrefSyntax.cs @@ -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); + } + } +} diff --git a/src/Compilers/CSharp/Portable/Syntax/OperatorDeclarationSyntax.cs b/src/Compilers/CSharp/Portable/Syntax/OperatorDeclarationSyntax.cs index 75c87324af6b2..c5ad2efc74ac6 100644 --- a/src/Compilers/CSharp/Portable/Syntax/OperatorDeclarationSyntax.cs +++ b/src/Compilers/CSharp/Portable/Syntax/OperatorDeclarationSyntax.cs @@ -29,5 +29,31 @@ public OperatorDeclarationSyntax Update( expressionBody: expressionBody, semicolonToken: semicolonToken); } + + public OperatorDeclarationSyntax Update( + SyntaxList attributeLists, + SyntaxTokenList modifiers, + TypeSyntax returnType, + ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, + SyntaxToken operatorKeyword, + SyntaxToken operatorToken, + ParameterListSyntax parameterList, + BlockSyntax? body, + ArrowExpressionClauseSyntax? expressionBody, + SyntaxToken semicolonToken) + { + return Update( + attributeLists: attributeLists, + modifiers: modifiers, + returnType: returnType, + explicitInterfaceSpecifier: explicitInterfaceSpecifier, + operatorKeyword: operatorKeyword, + checkedKeyword: this.CheckedKeyword, + operatorToken: operatorToken, + parameterList: parameterList, + body: body, + expressionBody: expressionBody, + semicolonToken: semicolonToken); + } } } diff --git a/src/Compilers/CSharp/Portable/Syntax/OperatorMemberCrefSyntax.cs b/src/Compilers/CSharp/Portable/Syntax/OperatorMemberCrefSyntax.cs new file mode 100644 index 0000000000000..99375a546abde --- /dev/null +++ b/src/Compilers/CSharp/Portable/Syntax/OperatorMemberCrefSyntax.cs @@ -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); + } + } +} diff --git a/src/Compilers/CSharp/Portable/Syntax/Syntax.xml b/src/Compilers/CSharp/Portable/Syntax/Syntax.xml index 5e3e42fb8337a..aef4a75a59c96 100644 --- a/src/Compilers/CSharp/Portable/Syntax/Syntax.xml +++ b/src/Compilers/CSharp/Portable/Syntax/Syntax.xml @@ -3798,6 +3798,12 @@ + + + Gets the "checked" keyword. + + + Gets the operator token. @@ -3862,6 +3868,12 @@ + + + Gets the "checked" keyword. + + + Gets the type. @@ -4341,6 +4353,9 @@ + + + Gets the operator token. @@ -4385,6 +4400,9 @@ + + + diff --git a/src/Compilers/CSharp/Portable/Syntax/SyntaxFactory.cs b/src/Compilers/CSharp/Portable/Syntax/SyntaxFactory.cs index c82a0bbc87ce6..eb9269263f2a1 100644 --- a/src/Compilers/CSharp/Portable/Syntax/SyntaxFactory.cs +++ b/src/Compilers/CSharp/Portable/Syntax/SyntaxFactory.cs @@ -2514,6 +2514,33 @@ public static ConversionOperatorDeclarationSyntax ConversionOperatorDeclaration( expressionBody: expressionBody); } + /// Creates a new instance. + public static ConversionOperatorDeclarationSyntax ConversionOperatorDeclaration( + SyntaxList attributeLists, + SyntaxTokenList modifiers, + SyntaxToken implicitOrExplicitKeyword, + ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, + SyntaxToken operatorKeyword, + TypeSyntax type, + ParameterListSyntax parameterList, + BlockSyntax? body, + ArrowExpressionClauseSyntax? expressionBody, + SyntaxToken semicolonToken) + { + return SyntaxFactory.ConversionOperatorDeclaration( + attributeLists: attributeLists, + modifiers: modifiers, + implicitOrExplicitKeyword: implicitOrExplicitKeyword, + explicitInterfaceSpecifier: explicitInterfaceSpecifier, + operatorKeyword: operatorKeyword, + checkedKeyword: default, + type: type, + parameterList: parameterList, + body: body, + expressionBody: expressionBody, + semicolonToken: semicolonToken); + } + /// Creates a new OperatorDeclarationSyntax instance. public static OperatorDeclarationSyntax OperatorDeclaration( SyntaxList attributeLists, @@ -2583,6 +2610,33 @@ public static OperatorDeclarationSyntax OperatorDeclaration( expressionBody: expressionBody); } + /// Creates a new instance. + public static OperatorDeclarationSyntax OperatorDeclaration( + SyntaxList attributeLists, + SyntaxTokenList modifiers, + TypeSyntax returnType, + ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier, + SyntaxToken operatorKeyword, + SyntaxToken operatorToken, + ParameterListSyntax parameterList, + BlockSyntax? body, + ArrowExpressionClauseSyntax? expressionBody, + SyntaxToken semicolonToken) + { + return SyntaxFactory.OperatorDeclaration( + attributeLists: attributeLists, + modifiers: modifiers, + returnType: returnType, + explicitInterfaceSpecifier: explicitInterfaceSpecifier, + operatorKeyword: operatorKeyword, + checkedKeyword: default, + operatorToken: operatorToken, + parameterList: parameterList, + body: body, + expressionBody: expressionBody, + semicolonToken: semicolonToken); + } + /// Creates a new UsingDirectiveSyntax instance. public static UsingDirectiveSyntax UsingDirective(NameEqualsSyntax alias, NameSyntax name) { @@ -2753,5 +2807,26 @@ public static SyntaxTree ParseSyntaxTree( { return CSharpSyntaxTree.ParseText(text, (CSharpParseOptions?)options, path, diagnosticOptions, isGeneratedCode, cancellationToken); } + + /// Creates a new instance. + public static OperatorMemberCrefSyntax OperatorMemberCref(SyntaxToken operatorKeyword, SyntaxToken operatorToken, CrefParameterListSyntax? parameters) + { + return SyntaxFactory.OperatorMemberCref( + operatorKeyword: operatorKeyword, + operatorToken: operatorToken, + checkedKeyword: default, + parameters: parameters); + } + + /// Creates a new instance. + public static ConversionOperatorMemberCrefSyntax ConversionOperatorMemberCref(SyntaxToken implicitOrExplicitKeyword, SyntaxToken operatorKeyword, TypeSyntax type, CrefParameterListSyntax? parameters) + { + return SyntaxFactory.ConversionOperatorMemberCref( + implicitOrExplicitKeyword: implicitOrExplicitKeyword, + operatorKeyword: operatorKeyword, + checkedKeyword: default, + type: type, + parameters: parameters); + } } } diff --git a/src/Compilers/CSharp/Test/Syntax/Generated/Syntax.Test.xml.Generated.cs b/src/Compilers/CSharp/Test/Syntax/Generated/Syntax.Test.xml.Generated.cs index caa4938c8e8ad..0f713bb591e6b 100644 --- a/src/Compilers/CSharp/Test/Syntax/Generated/Syntax.Test.xml.Generated.cs +++ b/src/Compilers/CSharp/Test/Syntax/Generated/Syntax.Test.xml.Generated.cs @@ -542,10 +542,10 @@ private static Syntax.InternalSyntax.MethodDeclarationSyntax GenerateMethodDecla => InternalSyntaxFactory.MethodDeclaration(new Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList(), new Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList(), GenerateIdentifierName(), null, InternalSyntaxFactory.Identifier("Identifier"), null, GenerateParameterList(), new Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList(), null, null, null); private static Syntax.InternalSyntax.OperatorDeclarationSyntax GenerateOperatorDeclaration() - => InternalSyntaxFactory.OperatorDeclaration(new Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList(), new Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList(), GenerateIdentifierName(), null, InternalSyntaxFactory.Token(SyntaxKind.OperatorKeyword), InternalSyntaxFactory.Token(SyntaxKind.PlusToken), GenerateParameterList(), null, null, null); + => InternalSyntaxFactory.OperatorDeclaration(new Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList(), new Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList(), GenerateIdentifierName(), null, InternalSyntaxFactory.Token(SyntaxKind.OperatorKeyword), null, InternalSyntaxFactory.Token(SyntaxKind.PlusToken), GenerateParameterList(), null, null, null); private static Syntax.InternalSyntax.ConversionOperatorDeclarationSyntax GenerateConversionOperatorDeclaration() - => InternalSyntaxFactory.ConversionOperatorDeclaration(new Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList(), new Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList(), InternalSyntaxFactory.Token(SyntaxKind.ImplicitKeyword), null, InternalSyntaxFactory.Token(SyntaxKind.OperatorKeyword), GenerateIdentifierName(), GenerateParameterList(), null, null, null); + => InternalSyntaxFactory.ConversionOperatorDeclaration(new Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList(), new Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList(), InternalSyntaxFactory.Token(SyntaxKind.ImplicitKeyword), null, InternalSyntaxFactory.Token(SyntaxKind.OperatorKeyword), null, GenerateIdentifierName(), GenerateParameterList(), null, null, null); private static Syntax.InternalSyntax.ConstructorDeclarationSyntax GenerateConstructorDeclaration() => InternalSyntaxFactory.ConstructorDeclaration(new Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList(), new Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList(), InternalSyntaxFactory.Identifier("Identifier"), GenerateParameterList(), null, null, null, null); @@ -608,10 +608,10 @@ private static Syntax.InternalSyntax.IndexerMemberCrefSyntax GenerateIndexerMemb => InternalSyntaxFactory.IndexerMemberCref(InternalSyntaxFactory.Token(SyntaxKind.ThisKeyword), null); private static Syntax.InternalSyntax.OperatorMemberCrefSyntax GenerateOperatorMemberCref() - => InternalSyntaxFactory.OperatorMemberCref(InternalSyntaxFactory.Token(SyntaxKind.OperatorKeyword), InternalSyntaxFactory.Token(SyntaxKind.PlusToken), null); + => InternalSyntaxFactory.OperatorMemberCref(InternalSyntaxFactory.Token(SyntaxKind.OperatorKeyword), null, InternalSyntaxFactory.Token(SyntaxKind.PlusToken), null); private static Syntax.InternalSyntax.ConversionOperatorMemberCrefSyntax GenerateConversionOperatorMemberCref() - => InternalSyntaxFactory.ConversionOperatorMemberCref(InternalSyntaxFactory.Token(SyntaxKind.ImplicitKeyword), InternalSyntaxFactory.Token(SyntaxKind.OperatorKeyword), GenerateIdentifierName(), null); + => InternalSyntaxFactory.ConversionOperatorMemberCref(InternalSyntaxFactory.Token(SyntaxKind.ImplicitKeyword), InternalSyntaxFactory.Token(SyntaxKind.OperatorKeyword), null, GenerateIdentifierName(), null); private static Syntax.InternalSyntax.CrefParameterListSyntax GenerateCrefParameterList() => InternalSyntaxFactory.CrefParameterList(InternalSyntaxFactory.Token(SyntaxKind.OpenParenToken), new Microsoft.CodeAnalysis.Syntax.InternalSyntax.SeparatedSyntaxList(), InternalSyntaxFactory.Token(SyntaxKind.CloseParenToken)); @@ -2968,6 +2968,7 @@ public void TestOperatorDeclarationFactoryAndProperties() Assert.NotNull(node.ReturnType); Assert.Null(node.ExplicitInterfaceSpecifier); Assert.Equal(SyntaxKind.OperatorKeyword, node.OperatorKeyword.Kind); + Assert.Null(node.CheckedKeyword); Assert.Equal(SyntaxKind.PlusToken, node.OperatorToken.Kind); Assert.NotNull(node.ParameterList); Assert.Null(node.Body); @@ -2987,6 +2988,7 @@ public void TestConversionOperatorDeclarationFactoryAndProperties() Assert.Equal(SyntaxKind.ImplicitKeyword, node.ImplicitOrExplicitKeyword.Kind); Assert.Null(node.ExplicitInterfaceSpecifier); Assert.Equal(SyntaxKind.OperatorKeyword, node.OperatorKeyword.Kind); + Assert.Null(node.CheckedKeyword); Assert.NotNull(node.Type); Assert.NotNull(node.ParameterList); Assert.Null(node.Body); @@ -3267,6 +3269,7 @@ public void TestOperatorMemberCrefFactoryAndProperties() var node = GenerateOperatorMemberCref(); Assert.Equal(SyntaxKind.OperatorKeyword, node.OperatorKeyword.Kind); + Assert.Null(node.CheckedKeyword); Assert.Equal(SyntaxKind.PlusToken, node.OperatorToken.Kind); Assert.Null(node.Parameters); @@ -3280,6 +3283,7 @@ public void TestConversionOperatorMemberCrefFactoryAndProperties() Assert.Equal(SyntaxKind.ImplicitKeyword, node.ImplicitOrExplicitKeyword.Kind); Assert.Equal(SyntaxKind.OperatorKeyword, node.OperatorKeyword.Kind); + Assert.Null(node.CheckedKeyword); Assert.NotNull(node.Type); Assert.Null(node.Parameters); @@ -10471,10 +10475,10 @@ private static MethodDeclarationSyntax GenerateMethodDeclaration() => SyntaxFactory.MethodDeclaration(new SyntaxList(), new SyntaxTokenList(), GenerateIdentifierName(), default(ExplicitInterfaceSpecifierSyntax), SyntaxFactory.Identifier("Identifier"), default(TypeParameterListSyntax), GenerateParameterList(), new SyntaxList(), default(BlockSyntax), default(ArrowExpressionClauseSyntax), default(SyntaxToken)); private static OperatorDeclarationSyntax GenerateOperatorDeclaration() - => SyntaxFactory.OperatorDeclaration(new SyntaxList(), new SyntaxTokenList(), GenerateIdentifierName(), default(ExplicitInterfaceSpecifierSyntax), SyntaxFactory.Token(SyntaxKind.OperatorKeyword), SyntaxFactory.Token(SyntaxKind.PlusToken), GenerateParameterList(), default(BlockSyntax), default(ArrowExpressionClauseSyntax), default(SyntaxToken)); + => SyntaxFactory.OperatorDeclaration(new SyntaxList(), new SyntaxTokenList(), GenerateIdentifierName(), default(ExplicitInterfaceSpecifierSyntax), SyntaxFactory.Token(SyntaxKind.OperatorKeyword), default(SyntaxToken), SyntaxFactory.Token(SyntaxKind.PlusToken), GenerateParameterList(), default(BlockSyntax), default(ArrowExpressionClauseSyntax), default(SyntaxToken)); private static ConversionOperatorDeclarationSyntax GenerateConversionOperatorDeclaration() - => SyntaxFactory.ConversionOperatorDeclaration(new SyntaxList(), new SyntaxTokenList(), SyntaxFactory.Token(SyntaxKind.ImplicitKeyword), default(ExplicitInterfaceSpecifierSyntax), SyntaxFactory.Token(SyntaxKind.OperatorKeyword), GenerateIdentifierName(), GenerateParameterList(), default(BlockSyntax), default(ArrowExpressionClauseSyntax), default(SyntaxToken)); + => SyntaxFactory.ConversionOperatorDeclaration(new SyntaxList(), new SyntaxTokenList(), SyntaxFactory.Token(SyntaxKind.ImplicitKeyword), default(ExplicitInterfaceSpecifierSyntax), SyntaxFactory.Token(SyntaxKind.OperatorKeyword), default(SyntaxToken), GenerateIdentifierName(), GenerateParameterList(), default(BlockSyntax), default(ArrowExpressionClauseSyntax), default(SyntaxToken)); private static ConstructorDeclarationSyntax GenerateConstructorDeclaration() => SyntaxFactory.ConstructorDeclaration(new SyntaxList(), new SyntaxTokenList(), SyntaxFactory.Identifier("Identifier"), GenerateParameterList(), default(ConstructorInitializerSyntax), default(BlockSyntax), default(ArrowExpressionClauseSyntax), default(SyntaxToken)); @@ -10537,10 +10541,10 @@ private static IndexerMemberCrefSyntax GenerateIndexerMemberCref() => SyntaxFactory.IndexerMemberCref(SyntaxFactory.Token(SyntaxKind.ThisKeyword), default(CrefBracketedParameterListSyntax)); private static OperatorMemberCrefSyntax GenerateOperatorMemberCref() - => SyntaxFactory.OperatorMemberCref(SyntaxFactory.Token(SyntaxKind.OperatorKeyword), SyntaxFactory.Token(SyntaxKind.PlusToken), default(CrefParameterListSyntax)); + => SyntaxFactory.OperatorMemberCref(SyntaxFactory.Token(SyntaxKind.OperatorKeyword), default(SyntaxToken), SyntaxFactory.Token(SyntaxKind.PlusToken), default(CrefParameterListSyntax)); private static ConversionOperatorMemberCrefSyntax GenerateConversionOperatorMemberCref() - => SyntaxFactory.ConversionOperatorMemberCref(SyntaxFactory.Token(SyntaxKind.ImplicitKeyword), SyntaxFactory.Token(SyntaxKind.OperatorKeyword), GenerateIdentifierName(), default(CrefParameterListSyntax)); + => SyntaxFactory.ConversionOperatorMemberCref(SyntaxFactory.Token(SyntaxKind.ImplicitKeyword), SyntaxFactory.Token(SyntaxKind.OperatorKeyword), default(SyntaxToken), GenerateIdentifierName(), default(CrefParameterListSyntax)); private static CrefParameterListSyntax GenerateCrefParameterList() => SyntaxFactory.CrefParameterList(SyntaxFactory.Token(SyntaxKind.OpenParenToken), new SeparatedSyntaxList(), SyntaxFactory.Token(SyntaxKind.CloseParenToken)); @@ -12897,12 +12901,13 @@ public void TestOperatorDeclarationFactoryAndProperties() Assert.NotNull(node.ReturnType); Assert.Null(node.ExplicitInterfaceSpecifier); Assert.Equal(SyntaxKind.OperatorKeyword, node.OperatorKeyword.Kind()); + Assert.Equal(SyntaxKind.None, node.CheckedKeyword.Kind()); Assert.Equal(SyntaxKind.PlusToken, node.OperatorToken.Kind()); Assert.NotNull(node.ParameterList); Assert.Null(node.Body); Assert.Null(node.ExpressionBody); Assert.Equal(SyntaxKind.None, node.SemicolonToken.Kind()); - var newNode = node.WithAttributeLists(node.AttributeLists).WithModifiers(node.Modifiers).WithReturnType(node.ReturnType).WithExplicitInterfaceSpecifier(node.ExplicitInterfaceSpecifier).WithOperatorKeyword(node.OperatorKeyword).WithOperatorToken(node.OperatorToken).WithParameterList(node.ParameterList).WithBody(node.Body).WithExpressionBody(node.ExpressionBody).WithSemicolonToken(node.SemicolonToken); + var newNode = node.WithAttributeLists(node.AttributeLists).WithModifiers(node.Modifiers).WithReturnType(node.ReturnType).WithExplicitInterfaceSpecifier(node.ExplicitInterfaceSpecifier).WithOperatorKeyword(node.OperatorKeyword).WithCheckedKeyword(node.CheckedKeyword).WithOperatorToken(node.OperatorToken).WithParameterList(node.ParameterList).WithBody(node.Body).WithExpressionBody(node.ExpressionBody).WithSemicolonToken(node.SemicolonToken); Assert.Equal(node, newNode); } @@ -12916,12 +12921,13 @@ public void TestConversionOperatorDeclarationFactoryAndProperties() Assert.Equal(SyntaxKind.ImplicitKeyword, node.ImplicitOrExplicitKeyword.Kind()); Assert.Null(node.ExplicitInterfaceSpecifier); Assert.Equal(SyntaxKind.OperatorKeyword, node.OperatorKeyword.Kind()); + Assert.Equal(SyntaxKind.None, node.CheckedKeyword.Kind()); Assert.NotNull(node.Type); Assert.NotNull(node.ParameterList); Assert.Null(node.Body); Assert.Null(node.ExpressionBody); Assert.Equal(SyntaxKind.None, node.SemicolonToken.Kind()); - var newNode = node.WithAttributeLists(node.AttributeLists).WithModifiers(node.Modifiers).WithImplicitOrExplicitKeyword(node.ImplicitOrExplicitKeyword).WithExplicitInterfaceSpecifier(node.ExplicitInterfaceSpecifier).WithOperatorKeyword(node.OperatorKeyword).WithType(node.Type).WithParameterList(node.ParameterList).WithBody(node.Body).WithExpressionBody(node.ExpressionBody).WithSemicolonToken(node.SemicolonToken); + var newNode = node.WithAttributeLists(node.AttributeLists).WithModifiers(node.Modifiers).WithImplicitOrExplicitKeyword(node.ImplicitOrExplicitKeyword).WithExplicitInterfaceSpecifier(node.ExplicitInterfaceSpecifier).WithOperatorKeyword(node.OperatorKeyword).WithCheckedKeyword(node.CheckedKeyword).WithType(node.Type).WithParameterList(node.ParameterList).WithBody(node.Body).WithExpressionBody(node.ExpressionBody).WithSemicolonToken(node.SemicolonToken); Assert.Equal(node, newNode); } @@ -13196,9 +13202,10 @@ public void TestOperatorMemberCrefFactoryAndProperties() var node = GenerateOperatorMemberCref(); Assert.Equal(SyntaxKind.OperatorKeyword, node.OperatorKeyword.Kind()); + Assert.Equal(SyntaxKind.None, node.CheckedKeyword.Kind()); Assert.Equal(SyntaxKind.PlusToken, node.OperatorToken.Kind()); Assert.Null(node.Parameters); - var newNode = node.WithOperatorKeyword(node.OperatorKeyword).WithOperatorToken(node.OperatorToken).WithParameters(node.Parameters); + var newNode = node.WithOperatorKeyword(node.OperatorKeyword).WithCheckedKeyword(node.CheckedKeyword).WithOperatorToken(node.OperatorToken).WithParameters(node.Parameters); Assert.Equal(node, newNode); } @@ -13209,9 +13216,10 @@ public void TestConversionOperatorMemberCrefFactoryAndProperties() Assert.Equal(SyntaxKind.ImplicitKeyword, node.ImplicitOrExplicitKeyword.Kind()); Assert.Equal(SyntaxKind.OperatorKeyword, node.OperatorKeyword.Kind()); + Assert.Equal(SyntaxKind.None, node.CheckedKeyword.Kind()); Assert.NotNull(node.Type); Assert.Null(node.Parameters); - var newNode = node.WithImplicitOrExplicitKeyword(node.ImplicitOrExplicitKeyword).WithOperatorKeyword(node.OperatorKeyword).WithType(node.Type).WithParameters(node.Parameters); + var newNode = node.WithImplicitOrExplicitKeyword(node.ImplicitOrExplicitKeyword).WithOperatorKeyword(node.OperatorKeyword).WithCheckedKeyword(node.CheckedKeyword).WithType(node.Type).WithParameters(node.Parameters); Assert.Equal(node, newNode); } diff --git a/src/Compilers/CSharp/Test/Syntax/Parsing/CrefParsingTests.cs b/src/Compilers/CSharp/Test/Syntax/Parsing/CrefParsingTests.cs index 7238a96dc69a8..ebda6659ca527 100644 --- a/src/Compilers/CSharp/Test/Syntax/Parsing/CrefParsingTests.cs +++ b/src/Compilers/CSharp/Test/Syntax/Parsing/CrefParsingTests.cs @@ -355,6 +355,19 @@ public void UnqualifiedOperatorMember1() } } + [Fact] + public void UnqualifiedOperatorMember1_Checked() + { + UsingNode("operator checked +"); + + N(SyntaxKind.OperatorMemberCref); + { + N(SyntaxKind.OperatorKeyword); + N(SyntaxKind.CheckedKeyword); + N(SyntaxKind.PlusToken); + } + } + [Fact] public void UnqualifiedOperatorMember2() { @@ -379,6 +392,31 @@ public void UnqualifiedOperatorMember2() } } + [Fact] + public void UnqualifiedOperatorMember2_Checked() + { + UsingNode("operator checked +(A)"); + + N(SyntaxKind.OperatorMemberCref); + { + N(SyntaxKind.OperatorKeyword); + N(SyntaxKind.CheckedKeyword); + N(SyntaxKind.PlusToken); + N(SyntaxKind.CrefParameterList); + { + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.CrefParameter); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken); + } + } + N(SyntaxKind.CloseParenToken); + } + } + } + #endregion Unqualified #region Qualified @@ -403,6 +441,27 @@ public void QualifiedOperatorMember1() } } + [Fact] + public void QualifiedOperatorMember1_Checked() + { + UsingNode("T.operator checked +"); + + N(SyntaxKind.QualifiedCref); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken); + } + N(SyntaxKind.DotToken); + N(SyntaxKind.OperatorMemberCref); + { + N(SyntaxKind.OperatorKeyword); + N(SyntaxKind.CheckedKeyword); + N(SyntaxKind.PlusToken); + } + } + } + [Fact] public void QualifiedOperatorMember2() { @@ -435,6 +494,39 @@ public void QualifiedOperatorMember2() } } + [Fact] + public void QualifiedOperatorMember2_Checked() + { + UsingNode("T.operator checked +(A)"); + + N(SyntaxKind.QualifiedCref); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken); + } + N(SyntaxKind.DotToken); + N(SyntaxKind.OperatorMemberCref); + { + N(SyntaxKind.OperatorKeyword); + N(SyntaxKind.CheckedKeyword); + N(SyntaxKind.PlusToken); + N(SyntaxKind.CrefParameterList); + { + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.CrefParameter); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken); + } + } + N(SyntaxKind.CloseParenToken); + } + } + } + } + #endregion Qualified #region Ambiguities @@ -483,6 +575,50 @@ public void GreaterThanGreaterThan() EOF(); } + [Fact] + public void GreaterThanGreaterThan_Checked() + { + UsingNode("operator checked }}(A{A{T}})"); + + N(SyntaxKind.OperatorMemberCref); + { + N(SyntaxKind.OperatorKeyword); + N(SyntaxKind.CheckedKeyword); + N(SyntaxKind.GreaterThanGreaterThanToken); // >> + N(SyntaxKind.CrefParameterList); + { + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.CrefParameter); + { + N(SyntaxKind.GenericName); + { + N(SyntaxKind.IdentifierToken); + N(SyntaxKind.TypeArgumentList); + { + N(SyntaxKind.LessThanToken); + N(SyntaxKind.GenericName); + { + N(SyntaxKind.IdentifierToken); + N(SyntaxKind.TypeArgumentList); + { + N(SyntaxKind.LessThanToken); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken); + } + N(SyntaxKind.GreaterThanToken); // just > + } + } + N(SyntaxKind.GreaterThanToken); // just > + } + } + } + N(SyntaxKind.CloseParenToken); + } + } + EOF(); + } + #endregion Ambiguities #endregion Operator Members @@ -507,6 +643,23 @@ public void UnqualifiedConversionOperatorMember1() } } + [Fact] + public void UnqualifiedConversionOperatorMember1_Checked() + { + UsingNode("implicit operator checked A"); + + N(SyntaxKind.ConversionOperatorMemberCref); + { + N(SyntaxKind.ImplicitKeyword); + N(SyntaxKind.OperatorKeyword); + N(SyntaxKind.CheckedKeyword); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken); + } + } + } + [Fact] public void UnqualifiedConversionOperatorMember2() { @@ -535,6 +688,35 @@ public void UnqualifiedConversionOperatorMember2() } } + [Fact] + public void UnqualifiedConversionOperatorMember2_Checked() + { + UsingNode("explicit operator checked A(B)"); + + N(SyntaxKind.ConversionOperatorMemberCref); + { + N(SyntaxKind.ExplicitKeyword); + N(SyntaxKind.OperatorKeyword); + N(SyntaxKind.CheckedKeyword); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken); + } + N(SyntaxKind.CrefParameterList); + { + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.CrefParameter); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken); + } + } + N(SyntaxKind.CloseParenToken); + } + } + } + #endregion Unqualified #region Qualified @@ -563,6 +745,31 @@ public void QualifiedConversionOperatorMember1() } } + [Fact] + public void QualifiedConversionOperatorMember1_Checked() + { + UsingNode("T.implicit operator checked A"); + + N(SyntaxKind.QualifiedCref); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken); + } + N(SyntaxKind.DotToken); + N(SyntaxKind.ConversionOperatorMemberCref); + { + N(SyntaxKind.ImplicitKeyword); + N(SyntaxKind.OperatorKeyword); + N(SyntaxKind.CheckedKeyword); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken); + } + } + } + } + [Fact] public void QualifiedConversionOperatorMember2() { @@ -599,6 +806,43 @@ public void QualifiedConversionOperatorMember2() } } + [Fact] + public void QualifiedConversionOperatorMember2_Checked() + { + UsingNode("T.explicit operator checked A(B)"); + + N(SyntaxKind.QualifiedCref); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken); + } + N(SyntaxKind.DotToken); + N(SyntaxKind.ConversionOperatorMemberCref); + { + N(SyntaxKind.ExplicitKeyword); + N(SyntaxKind.OperatorKeyword); + N(SyntaxKind.CheckedKeyword); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken); + } + N(SyntaxKind.CrefParameterList); + { + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.CrefParameter); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken); + } + } + N(SyntaxKind.CloseParenToken); + } + } + } + } + #endregion Qualified #endregion Conversion Operator Members @@ -1143,6 +1387,36 @@ public void PrimitiveArrayReturnType() EOF(); } + [Fact] + public void PrimitiveArrayReturnType_Checked() + { + UsingNode("explicit operator checked int[]"); + + N(SyntaxKind.ConversionOperatorMemberCref); + { + N(SyntaxKind.ExplicitKeyword); + N(SyntaxKind.OperatorKeyword); + N(SyntaxKind.CheckedKeyword); + N(SyntaxKind.ArrayType); + { + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); + } + N(SyntaxKind.ArrayRankSpecifier); + { + N(SyntaxKind.OpenBracketToken); + N(SyntaxKind.OmittedArraySizeExpression); + { + N(SyntaxKind.OmittedArraySizeExpressionToken); + } + N(SyntaxKind.CloseBracketToken); + } + } + } + EOF(); + } + [WorkItem(531154, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/531154")] [Fact] public void NamedTypeArrayReturnType() @@ -1173,6 +1447,36 @@ public void NamedTypeArrayReturnType() EOF(); } + [Fact] + public void NamedTypeArrayReturnType_Checked() + { + UsingNode("explicit operator checked C[]"); + + N(SyntaxKind.ConversionOperatorMemberCref); + { + N(SyntaxKind.ExplicitKeyword); + N(SyntaxKind.OperatorKeyword); + N(SyntaxKind.CheckedKeyword); + N(SyntaxKind.ArrayType); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken); + } + N(SyntaxKind.ArrayRankSpecifier); + { + N(SyntaxKind.OpenBracketToken); + N(SyntaxKind.OmittedArraySizeExpression); + { + N(SyntaxKind.OmittedArraySizeExpressionToken); + } + N(SyntaxKind.CloseBracketToken); + } + } + } + EOF(); + } + #endregion Conversion operator return types #region Qualified diff --git a/src/Compilers/CSharp/Test/Syntax/Parsing/MemberDeclarationParsingTests.cs b/src/Compilers/CSharp/Test/Syntax/Parsing/MemberDeclarationParsingTests.cs index e6182b885b207..753484875c47e 100644 --- a/src/Compilers/CSharp/Test/Syntax/Parsing/MemberDeclarationParsingTests.cs +++ b/src/Compilers/CSharp/Test/Syntax/Parsing/MemberDeclarationParsingTests.cs @@ -6893,5 +6893,339 @@ public void MisplacedColonColon_05() EOF(); } } + + [Theory] + [InlineData("+", SyntaxKind.PlusToken)] + [InlineData("-", SyntaxKind.MinusToken)] + [InlineData("!", SyntaxKind.ExclamationToken)] + [InlineData("~", SyntaxKind.TildeToken)] + [InlineData("++", SyntaxKind.PlusPlusToken)] + [InlineData("--", SyntaxKind.MinusMinusToken)] + [InlineData("true", SyntaxKind.TrueKeyword)] + [InlineData("false", SyntaxKind.FalseKeyword)] + public void CheckedOperatorDeclaration_01(string op, SyntaxKind opToken) + { + UsingDeclaration("C operator checked " + op + "(C x) => x;"); + + N(SyntaxKind.OperatorDeclaration); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "C"); + } + N(SyntaxKind.OperatorKeyword); + N(SyntaxKind.CheckedKeyword); + N(opToken); + N(SyntaxKind.ParameterList); + { + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.Parameter); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "C"); + } + N(SyntaxKind.IdentifierToken, "x"); + } + N(SyntaxKind.CloseParenToken); + } + N(SyntaxKind.ArrowExpressionClause); + { + N(SyntaxKind.EqualsGreaterThanToken); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } + } + N(SyntaxKind.SemicolonToken); + } + EOF(); + } + + [Theory] + [InlineData("+", SyntaxKind.PlusToken)] + [InlineData("-", SyntaxKind.MinusToken)] + [InlineData("!", SyntaxKind.ExclamationToken)] + [InlineData("~", SyntaxKind.TildeToken)] + [InlineData("++", SyntaxKind.PlusPlusToken)] + [InlineData("--", SyntaxKind.MinusMinusToken)] + [InlineData("true", SyntaxKind.TrueKeyword)] + [InlineData("false", SyntaxKind.FalseKeyword)] + public void CheckedOperatorDeclaration_02(string op, SyntaxKind opToken) + { + UsingDeclaration("C I.operator checked " + op + "(C x) => x;", options: TestOptions.RegularPreview); + + N(SyntaxKind.OperatorDeclaration); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "C"); + } + N(SyntaxKind.ExplicitInterfaceSpecifier); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "I"); + } + N(SyntaxKind.DotToken); + } + N(SyntaxKind.OperatorKeyword); + N(SyntaxKind.CheckedKeyword); + N(opToken); + N(SyntaxKind.ParameterList); + { + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.Parameter); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "C"); + } + N(SyntaxKind.IdentifierToken, "x"); + } + N(SyntaxKind.CloseParenToken); + } + N(SyntaxKind.ArrowExpressionClause); + { + N(SyntaxKind.EqualsGreaterThanToken); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } + } + N(SyntaxKind.SemicolonToken); + } + EOF(); + } + + [Theory] + [InlineData("+", SyntaxKind.PlusToken)] + [InlineData("-", SyntaxKind.MinusToken)] + [InlineData("*", SyntaxKind.AsteriskToken)] + [InlineData("/", SyntaxKind.SlashToken)] + [InlineData("%", SyntaxKind.PercentToken)] + [InlineData("&", SyntaxKind.AmpersandToken)] + [InlineData("|", SyntaxKind.BarToken)] + [InlineData("^", SyntaxKind.CaretToken)] + [InlineData("<<", SyntaxKind.LessThanLessThanToken)] + [InlineData(">>", SyntaxKind.GreaterThanGreaterThanToken)] + [InlineData("==", SyntaxKind.EqualsEqualsToken)] + [InlineData("!=", SyntaxKind.ExclamationEqualsToken)] + [InlineData(">", SyntaxKind.GreaterThanToken)] + [InlineData("<", SyntaxKind.LessThanToken)] + [InlineData(">=", SyntaxKind.GreaterThanEqualsToken)] + [InlineData("<=", SyntaxKind.LessThanEqualsToken)] + public void CheckedOperatorDeclaration_03(string op, SyntaxKind opToken) + { + UsingDeclaration("C operator checked " + op + "(C x, C y) => x;"); + + N(SyntaxKind.OperatorDeclaration); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "C"); + } + N(SyntaxKind.OperatorKeyword); + N(SyntaxKind.CheckedKeyword); + N(opToken); + N(SyntaxKind.ParameterList); + { + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.Parameter); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "C"); + } + N(SyntaxKind.IdentifierToken, "x"); + } + N(SyntaxKind.CommaToken); + N(SyntaxKind.Parameter); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "C"); + } + N(SyntaxKind.IdentifierToken, "y"); + } + N(SyntaxKind.CloseParenToken); + } + N(SyntaxKind.ArrowExpressionClause); + { + N(SyntaxKind.EqualsGreaterThanToken); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } + } + N(SyntaxKind.SemicolonToken); + } + EOF(); + } + + [Theory] + [InlineData("+", SyntaxKind.PlusToken)] + [InlineData("-", SyntaxKind.MinusToken)] + [InlineData("*", SyntaxKind.AsteriskToken)] + [InlineData("/", SyntaxKind.SlashToken)] + [InlineData("%", SyntaxKind.PercentToken)] + [InlineData("&", SyntaxKind.AmpersandToken)] + [InlineData("|", SyntaxKind.BarToken)] + [InlineData("^", SyntaxKind.CaretToken)] + [InlineData("<<", SyntaxKind.LessThanLessThanToken)] + [InlineData(">>", SyntaxKind.GreaterThanGreaterThanToken)] + [InlineData("==", SyntaxKind.EqualsEqualsToken)] + [InlineData("!=", SyntaxKind.ExclamationEqualsToken)] + [InlineData(">", SyntaxKind.GreaterThanToken)] + [InlineData("<", SyntaxKind.LessThanToken)] + [InlineData(">=", SyntaxKind.GreaterThanEqualsToken)] + [InlineData("<=", SyntaxKind.LessThanEqualsToken)] + public void CheckedOperatorDeclaration_04(string op, SyntaxKind opToken) + { + UsingDeclaration("C I.operator checked " + op + "(C x, C y) => x;", options: TestOptions.RegularPreview); + + N(SyntaxKind.OperatorDeclaration); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "C"); + } + N(SyntaxKind.ExplicitInterfaceSpecifier); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "I"); + } + N(SyntaxKind.DotToken); + } + N(SyntaxKind.OperatorKeyword); + N(SyntaxKind.CheckedKeyword); + N(opToken); + N(SyntaxKind.ParameterList); + { + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.Parameter); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "C"); + } + N(SyntaxKind.IdentifierToken, "x"); + } + N(SyntaxKind.CommaToken); + N(SyntaxKind.Parameter); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "C"); + } + N(SyntaxKind.IdentifierToken, "y"); + } + N(SyntaxKind.CloseParenToken); + } + N(SyntaxKind.ArrowExpressionClause); + { + N(SyntaxKind.EqualsGreaterThanToken); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } + } + N(SyntaxKind.SemicolonToken); + } + EOF(); + } + + [Theory] + [InlineData("implicit", SyntaxKind.ImplicitKeyword)] + [InlineData("explicit", SyntaxKind.ExplicitKeyword)] + public void CheckedOperatorDeclaration_05(string op, SyntaxKind opToken) + { + UsingDeclaration(op + " operator checked D(C x) => x;"); + + N(SyntaxKind.ConversionOperatorDeclaration); + { + N(opToken); + N(SyntaxKind.OperatorKeyword); + N(SyntaxKind.CheckedKeyword); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "D"); + } + N(SyntaxKind.ParameterList); + { + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.Parameter); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "C"); + } + N(SyntaxKind.IdentifierToken, "x"); + } + N(SyntaxKind.CloseParenToken); + } + N(SyntaxKind.ArrowExpressionClause); + { + N(SyntaxKind.EqualsGreaterThanToken); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } + } + N(SyntaxKind.SemicolonToken); + } + EOF(); + } + + [Theory] + [InlineData("implicit", SyntaxKind.ImplicitKeyword)] + [InlineData("explicit", SyntaxKind.ExplicitKeyword)] + public void CheckedOperatorDeclaration_06(string op, SyntaxKind opToken) + { + UsingDeclaration(op + " I.operator checked D(C x) => x;", options: TestOptions.RegularPreview); + + N(SyntaxKind.ConversionOperatorDeclaration); + { + N(opToken); + N(SyntaxKind.ExplicitInterfaceSpecifier); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "I"); + } + N(SyntaxKind.DotToken); + } + N(SyntaxKind.OperatorKeyword); + N(SyntaxKind.CheckedKeyword); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "D"); + } + N(SyntaxKind.ParameterList); + { + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.Parameter); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "C"); + } + N(SyntaxKind.IdentifierToken, "x"); + } + N(SyntaxKind.CloseParenToken); + } + N(SyntaxKind.ArrowExpressionClause); + { + N(SyntaxKind.EqualsGreaterThanToken); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } + } + N(SyntaxKind.SemicolonToken); + } + EOF(); + } } }