diff --git a/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs b/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs index 5135485a3ce72f70de3c9cd1fea595c60fbea0a2..fa73dc8118c274c1cc1f45da7690912b10aa62c7 100644 --- a/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs +++ b/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs @@ -914,15 +914,15 @@ private IConditionalChoiceExpression CreateBoundConditionalOperatorOperation(Bou return new LazyConditionalChoiceExpression(condition, ifTrueValue, ifFalseValue, _semanticModel, syntax, type, constantValue, isImplicit); } - private INullCoalescingExpression CreateBoundNullCoalescingOperatorOperation(BoundNullCoalescingOperator boundNullCoalescingOperator) + private ICoalesceExpression CreateBoundNullCoalescingOperatorOperation(BoundNullCoalescingOperator boundNullCoalescingOperator) { - Lazy primaryOperand = new Lazy(() => Create(boundNullCoalescingOperator.LeftOperand)); - Lazy secondaryOperand = new Lazy(() => Create(boundNullCoalescingOperator.RightOperand)); + Lazy expression = new Lazy(() => Create(boundNullCoalescingOperator.LeftOperand)); + Lazy whenNull = new Lazy(() => Create(boundNullCoalescingOperator.RightOperand)); SyntaxNode syntax = boundNullCoalescingOperator.Syntax; ITypeSymbol type = boundNullCoalescingOperator.Type; Optional constantValue = ConvertToOptional(boundNullCoalescingOperator.ConstantValue); bool isImplicit = boundNullCoalescingOperator.WasCompilerGenerated; - return new LazyNullCoalescingExpression(primaryOperand, secondaryOperand, _semanticModel, syntax, type, constantValue, isImplicit); + return new LazyCoalesceExpression(expression, whenNull, _semanticModel, syntax, type, constantValue, isImplicit); } private IAwaitExpression CreateBoundAwaitExpressionOperation(BoundAwaitExpression boundAwaitExpression) diff --git a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IConversionExpression.cs b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IConversionExpression.cs index 3f9ef82c381f6ceccab9b92b55487375817c7242..826c3e22ec371543dc1e38216899729c98d0e1b8 100644 --- a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IConversionExpression.cs +++ b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IConversionExpression.cs @@ -318,11 +318,11 @@ static void Main(string[] args) IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'object /**/;') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'object /**/;') Variables: Local_1: System.Object o - Initializer: INullCoalescingExpression (OperationKind.NullCoalescingExpression, Type: System.Object) (Syntax: 'new object( ... Exception()') - Left: IObjectCreationExpression (Constructor: System.Object..ctor()) (OperationKind.ObjectCreationExpression, Type: System.Object) (Syntax: 'new object()') + Initializer: ICoalesceExpression (OperationKind.CoalesceExpression, Type: System.Object) (Syntax: 'new object( ... Exception()') + Expression: IObjectCreationExpression (Constructor: System.Object..ctor()) (OperationKind.ObjectCreationExpression, Type: System.Object) (Syntax: 'new object()') Arguments(0) Initializer: null - Right: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Object) (Syntax: 'throw new Exception()') + WhenNull: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Object) (Syntax: 'throw new Exception()') Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) Operand: IThrowExpression (OperationKind.ThrowExpression, Type: null) (Syntax: 'throw new Exception()') IObjectCreationExpression (Constructor: System.Exception..ctor()) (OperationKind.ObjectCreationExpression, Type: System.Exception) (Syntax: 'new Exception()') @@ -342,7 +342,7 @@ static void Main(string[] args) OperationSelector = (operation) => { var initializer = ((IVariableDeclarationStatement)operation).Declarations.Single().Initializer; - return (IConversionExpression)((INullCoalescingExpression)initializer).SecondaryOperand; + return (IConversionExpression)((ICoalesceExpression)initializer).WhenNull; } }.Verify); } diff --git a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs index 28695f49c7004595aa172a1a0cb2c726d3c5ac41..8d67ce4ead9f76f8e006828c9d55120194d813d4 100644 --- a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs +++ b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs @@ -3039,74 +3039,74 @@ internal sealed partial class LazyMethodBindingExpression : BaseMethodBindingExp /// /// Represents a null-coalescing expression. /// - internal abstract partial class BaseNullCoalescingExpression : Operation, INullCoalescingExpression + internal abstract partial class BaseCoalesceExpression : Operation, ICoalesceExpression { - protected BaseNullCoalescingExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : - base(OperationKind.NullCoalescingExpression, semanticModel, syntax, type, constantValue, isImplicit) + protected BaseCoalesceExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.CoalesceExpression, semanticModel, syntax, type, constantValue, isImplicit) { } - protected abstract IOperation PrimaryOperandImpl { get; } - protected abstract IOperation SecondaryOperandImpl { get; } + protected abstract IOperation ExpressionImpl { get; } + protected abstract IOperation WhenNullImpl { get; } public override IEnumerable Children { get { - yield return PrimaryOperand; - yield return SecondaryOperand; + yield return Expression; + yield return WhenNull; } } /// /// Value to be unconditionally evaluated. /// - public IOperation PrimaryOperand => Operation.SetParentOperation(PrimaryOperandImpl, this); + public IOperation Expression => Operation.SetParentOperation(ExpressionImpl, this); /// - /// Value to be evaluated if Primary evaluates to null/Nothing. + /// Value to be evaluated if evaluates to null/Nothing. /// - public IOperation SecondaryOperand => Operation.SetParentOperation(SecondaryOperandImpl, this); + public IOperation WhenNull => Operation.SetParentOperation(WhenNullImpl, this); public override void Accept(OperationVisitor visitor) { - visitor.VisitNullCoalescingExpression(this); + visitor.VisitCoalesceExpression(this); } public override TResult Accept(OperationVisitor visitor, TArgument argument) { - return visitor.VisitNullCoalescingExpression(this, argument); + return visitor.VisitCoalesceExpression(this, argument); } } /// /// Represents a null-coalescing expression. /// - internal sealed partial class NullCoalescingExpression : BaseNullCoalescingExpression, INullCoalescingExpression + internal sealed partial class CoalesceExpression : BaseCoalesceExpression, ICoalesceExpression { - public NullCoalescingExpression(IOperation primaryOperand, IOperation secondaryOperand, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + public CoalesceExpression(IOperation expression, IOperation whenNull, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit) { - PrimaryOperandImpl = primaryOperand; - SecondaryOperandImpl = secondaryOperand; + ExpressionImpl = expression; + WhenNullImpl = whenNull; } - protected override IOperation PrimaryOperandImpl { get; } - protected override IOperation SecondaryOperandImpl { get; } + protected override IOperation ExpressionImpl { get; } + protected override IOperation WhenNullImpl { get; } } /// /// Represents a null-coalescing expression. /// - internal sealed partial class LazyNullCoalescingExpression : BaseNullCoalescingExpression, INullCoalescingExpression + internal sealed partial class LazyCoalesceExpression : BaseCoalesceExpression, ICoalesceExpression { - private readonly Lazy _lazyPrimaryOperand; - private readonly Lazy _lazySecondaryOperand; + private readonly Lazy _lazyExpression; + private readonly Lazy _lazyWhenNull; - public LazyNullCoalescingExpression(Lazy primaryOperand, Lazy secondaryOperand, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit) + public LazyCoalesceExpression(Lazy expression, Lazy whenNull, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit) { - _lazyPrimaryOperand = primaryOperand ?? throw new System.ArgumentNullException(nameof(primaryOperand)); - _lazySecondaryOperand = secondaryOperand ?? throw new System.ArgumentNullException(nameof(secondaryOperand)); + _lazyExpression = expression ?? throw new System.ArgumentNullException(nameof(expression)); + _lazyWhenNull = whenNull ?? throw new System.ArgumentNullException(nameof(whenNull)); } - protected override IOperation PrimaryOperandImpl => _lazyPrimaryOperand.Value; + protected override IOperation ExpressionImpl => _lazyExpression.Value; - protected override IOperation SecondaryOperandImpl => _lazySecondaryOperand.Value; + protected override IOperation WhenNullImpl => _lazyWhenNull.Value; } /// diff --git a/src/Compilers/Core/Portable/Operations/INullCoalescingExpression.cs b/src/Compilers/Core/Portable/Operations/ICoalesceExpression.cs similarity index 75% rename from src/Compilers/Core/Portable/Operations/INullCoalescingExpression.cs rename to src/Compilers/Core/Portable/Operations/ICoalesceExpression.cs index 9f64b19bf8df0ba6c07e3a2acf33cf8f432e3133..197933ede9db03d52ced0bbb68fd44677d4991a9 100644 --- a/src/Compilers/Core/Portable/Operations/INullCoalescingExpression.cs +++ b/src/Compilers/Core/Portable/Operations/ICoalesceExpression.cs @@ -11,16 +11,16 @@ namespace Microsoft.CodeAnalysis.Semantics /// This interface is reserved for implementation by its associated APIs. We reserve the right to /// change it in the future. /// - public interface INullCoalescingExpression : IOperation + public interface ICoalesceExpression : IOperation { /// /// Value to be unconditionally evaluated. /// - IOperation PrimaryOperand { get; } + IOperation Expression { get; } /// - /// Value to be evaluated if Primary evaluates to null/Nothing. + /// Value to be evaluated if evaluates to null/Nothing. /// - IOperation SecondaryOperand { get; } + IOperation WhenNull { get; } } } diff --git a/src/Compilers/Core/Portable/Operations/OperationCloner.cs b/src/Compilers/Core/Portable/Operations/OperationCloner.cs index 7d74468a3535f0adb17c5098bdfdaa3445d3c683..f4aa4106d02f33def36548714cbc2d0afc6c75e4 100644 --- a/src/Compilers/Core/Portable/Operations/OperationCloner.cs +++ b/src/Compilers/Core/Portable/Operations/OperationCloner.cs @@ -274,9 +274,9 @@ public override IOperation VisitConditionalChoiceExpression(IConditionalChoiceEx return new ConditionalChoiceExpression(Visit(operation.Condition), Visit(operation.IfTrueValue), Visit(operation.IfFalseValue), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } - public override IOperation VisitNullCoalescingExpression(INullCoalescingExpression operation, object argument) + public override IOperation VisitCoalesceExpression(ICoalesceExpression operation, object argument) { - return new NullCoalescingExpression(Visit(operation.PrimaryOperand), Visit(operation.SecondaryOperand), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); + return new CoalesceExpression(Visit(operation.Expression), Visit(operation.WhenNull), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitIsTypeExpression(IIsTypeExpression operation, object argument) diff --git a/src/Compilers/Core/Portable/Operations/OperationKind.cs b/src/Compilers/Core/Portable/Operations/OperationKind.cs index f0a17227330cd8ab9b30c21b03f9cccdb031dc07..5023d3c517a72e48ecdf427f0bb741bef0044e87 100644 --- a/src/Compilers/Core/Portable/Operations/OperationKind.cs +++ b/src/Compilers/Core/Portable/Operations/OperationKind.cs @@ -96,8 +96,8 @@ public enum OperationKind BinaryOperatorExpression = 0x10e, /// Indicates an . ConditionalChoiceExpression = 0x10f, - /// Indicates an . - NullCoalescingExpression = 0x110, + /// Indicates an . + CoalesceExpression = 0x110, /// Indicates an . LambdaExpression = 0x111, /// Indicates an . diff --git a/src/Compilers/Core/Portable/Operations/OperationVisitor.cs b/src/Compilers/Core/Portable/Operations/OperationVisitor.cs index 56c1f3b4db0930e0997b627af2d4bd6cb5879ebf..65d6ffdf9c4bafb3fc635924e6a24439f04f752c 100644 --- a/src/Compilers/Core/Portable/Operations/OperationVisitor.cs +++ b/src/Compilers/Core/Portable/Operations/OperationVisitor.cs @@ -270,7 +270,7 @@ public virtual void VisitConditionalChoiceExpression(IConditionalChoiceExpressio DefaultVisit(operation); } - public virtual void VisitNullCoalescingExpression(INullCoalescingExpression operation) + public virtual void VisitCoalesceExpression(ICoalesceExpression operation) { DefaultVisit(operation); } @@ -740,7 +740,7 @@ public virtual TResult VisitConditionalChoiceExpression(IConditionalChoiceExpres return DefaultVisit(operation, argument); } - public virtual TResult VisitNullCoalescingExpression(INullCoalescingExpression operation, TArgument argument) + public virtual TResult VisitCoalesceExpression(ICoalesceExpression operation, TArgument argument) { return DefaultVisit(operation, argument); } diff --git a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt index d96880317d1353c204d51be6a37a0f57ecd7a834..b43b96d0be050c27a7fd96d6e9e2fda4bdf07057 100644 --- a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt +++ b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt @@ -101,7 +101,7 @@ Microsoft.CodeAnalysis.OperationKind.MemberInitializerExpression = 289 -> Micros Microsoft.CodeAnalysis.OperationKind.MethodBindingExpression = 265 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.NameOfExpression = 291 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.None = 0 -> Microsoft.CodeAnalysis.OperationKind -Microsoft.CodeAnalysis.OperationKind.NullCoalescingExpression = 272 -> Microsoft.CodeAnalysis.OperationKind +Microsoft.CodeAnalysis.OperationKind.CoalesceExpression = 272 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.ObjectCreationExpression = 274 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.ObjectOrCollectionInitializerExpression = 288 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.OmittedArgumentExpression = 768 -> Microsoft.CodeAnalysis.OperationKind @@ -512,9 +512,9 @@ Microsoft.CodeAnalysis.Semantics.IMethodBindingExpression.IsVirtual.get -> bool Microsoft.CodeAnalysis.Semantics.IMethodBindingExpression.Method.get -> Microsoft.CodeAnalysis.IMethodSymbol Microsoft.CodeAnalysis.Semantics.INameOfExpression Microsoft.CodeAnalysis.Semantics.INameOfExpression.Argument.get -> Microsoft.CodeAnalysis.IOperation -Microsoft.CodeAnalysis.Semantics.INullCoalescingExpression -Microsoft.CodeAnalysis.Semantics.INullCoalescingExpression.PrimaryOperand.get -> Microsoft.CodeAnalysis.IOperation -Microsoft.CodeAnalysis.Semantics.INullCoalescingExpression.SecondaryOperand.get -> Microsoft.CodeAnalysis.IOperation +Microsoft.CodeAnalysis.Semantics.ICoalesceExpression +Microsoft.CodeAnalysis.Semantics.ICoalesceExpression.Expression.get -> Microsoft.CodeAnalysis.IOperation +Microsoft.CodeAnalysis.Semantics.ICoalesceExpression.WhenNull.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IObjectCreationExpression Microsoft.CodeAnalysis.Semantics.IObjectCreationExpression.Constructor.get -> Microsoft.CodeAnalysis.IMethodSymbol Microsoft.CodeAnalysis.Semantics.IObjectCreationExpression.Initializer.get -> Microsoft.CodeAnalysis.Semantics.IObjectOrCollectionInitializerExpression @@ -828,7 +828,7 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitLockStatement(Mic virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitMemberInitializerExpression(Microsoft.CodeAnalysis.Semantics.IMemberInitializerExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitMethodBindingExpression(Microsoft.CodeAnalysis.Semantics.IMethodBindingExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitNameOfExpression(Microsoft.CodeAnalysis.Semantics.INameOfExpression operation) -> void -virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitNullCoalescingExpression(Microsoft.CodeAnalysis.Semantics.INullCoalescingExpression operation) -> void +virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitCoalesceExpression(Microsoft.CodeAnalysis.Semantics.ICoalesceExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitObjectCreationExpression(Microsoft.CodeAnalysis.Semantics.IObjectCreationExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitObjectOrCollectionInitializerExpression(Microsoft.CodeAnalysis.Semantics.IObjectOrCollectionInitializerExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitOmittedArgumentExpression(Microsoft.CodeAnalysis.Semantics.IOmittedArgumentExpression operation) -> void @@ -918,7 +918,7 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.Vi virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitMemberInitializerExpression(Microsoft.CodeAnalysis.Semantics.IMemberInitializerExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitMethodBindingExpression(Microsoft.CodeAnalysis.Semantics.IMethodBindingExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitNameOfExpression(Microsoft.CodeAnalysis.Semantics.INameOfExpression operation, TArgument argument) -> TResult -virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitNullCoalescingExpression(Microsoft.CodeAnalysis.Semantics.INullCoalescingExpression operation, TArgument argument) -> TResult +virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitCoalesceExpression(Microsoft.CodeAnalysis.Semantics.ICoalesceExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitObjectCreationExpression(Microsoft.CodeAnalysis.Semantics.IObjectCreationExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitObjectOrCollectionInitializerExpression(Microsoft.CodeAnalysis.Semantics.IObjectOrCollectionInitializerExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitOmittedArgumentExpression(Microsoft.CodeAnalysis.Semantics.IOmittedArgumentExpression operation, TArgument argument) -> TResult diff --git a/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb b/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb index c763cd9333d0578f6a1afb5001f41b5e733749c2..64f079c606814d5f8e2877c2819dfc577b281120 100644 --- a/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb +++ b/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb @@ -295,7 +295,7 @@ Namespace Microsoft.CodeAnalysis.Semantics End Function Private Function CreateBoundMyBaseReferenceOperation(boundMyBaseReference As BoundMyBaseReference) As IInstanceReferenceExpression - Dim instanceReferenceKind As InstanceReferenceKind = instanceReferenceKind.BaseClass + Dim instanceReferenceKind As InstanceReferenceKind = InstanceReferenceKind.BaseClass Dim syntax As SyntaxNode = boundMyBaseReference.Syntax Dim type As ITypeSymbol = boundMyBaseReference.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundMyBaseReference.ConstantValueOpt) @@ -304,7 +304,7 @@ Namespace Microsoft.CodeAnalysis.Semantics End Function Private Function CreateBoundMyClassReferenceOperation(boundMyClassReference As BoundMyClassReference) As IInstanceReferenceExpression - Dim instanceReferenceKind As InstanceReferenceKind = instanceReferenceKind.ThisClass + Dim instanceReferenceKind As InstanceReferenceKind = InstanceReferenceKind.ThisClass Dim syntax As SyntaxNode = boundMyClassReference.Syntax Dim type As ITypeSymbol = boundMyClassReference.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundMyClassReference.ConstantValueOpt) @@ -460,18 +460,18 @@ Namespace Microsoft.CodeAnalysis.Semantics Return New LazyBinaryOperatorExpression(binaryOperationKind, leftOperand, rightOperand, isLifted, usesOperatorMethod, operatorMethod, _semanticModel, syntax, type, constantValue, isImplicit) End Function - Private Function CreateBoundBinaryConditionalExpressionOperation(boundBinaryConditionalExpression As BoundBinaryConditionalExpression) As INullCoalescingExpression - Dim primaryOperand As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() Create(boundBinaryConditionalExpression.TestExpression)) - Dim secondaryOperand As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() Create(boundBinaryConditionalExpression.ElseExpression)) + Private Function CreateBoundBinaryConditionalExpressionOperation(boundBinaryConditionalExpression As BoundBinaryConditionalExpression) As ICoalesceExpression + Dim expression As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() Create(boundBinaryConditionalExpression.TestExpression)) + Dim whenNull As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() Create(boundBinaryConditionalExpression.ElseExpression)) Dim syntax As SyntaxNode = boundBinaryConditionalExpression.Syntax Dim type As ITypeSymbol = boundBinaryConditionalExpression.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundBinaryConditionalExpression.ConstantValueOpt) Dim isImplicit As Boolean = boundBinaryConditionalExpression.WasCompilerGenerated - Return New LazyNullCoalescingExpression(primaryOperand, secondaryOperand, _semanticModel, syntax, type, constantValue, isImplicit) + Return New LazyCoalesceExpression(expression, whenNull, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundUserDefinedShortCircuitingOperatorOperation(boundUserDefinedShortCircuitingOperator As BoundUserDefinedShortCircuitingOperator) As IBinaryOperatorExpression - Dim binaryOperationKind As BinaryOperationKind = If((boundUserDefinedShortCircuitingOperator.BitwiseOperator.OperatorKind And BinaryOperatorKind.And) <> 0, binaryOperationKind.OperatorMethodConditionalAnd, binaryOperationKind.OperatorMethodConditionalOr) + Dim binaryOperationKind As BinaryOperationKind = If((boundUserDefinedShortCircuitingOperator.BitwiseOperator.OperatorKind And BinaryOperatorKind.And) <> 0, BinaryOperationKind.OperatorMethodConditionalAnd, BinaryOperationKind.OperatorMethodConditionalOr) Dim leftOperand As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() Create(boundUserDefinedShortCircuitingOperator.LeftOperand)) Dim rightOperand As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() Create(boundUserDefinedShortCircuitingOperator.BitwiseOperator.Right)) Dim usesOperatorMethod As Boolean = True diff --git a/src/Features/Core/Portable/InitializeParameter/AbstractAddParameterCheckCodeRefactoringProvider.cs b/src/Features/Core/Portable/InitializeParameter/AbstractAddParameterCheckCodeRefactoringProvider.cs index cbc58c586469f6ad1247a7242fa94e03805397bf..86c89802aaae276a4fc38e1c75eb61b7621c341e 100644 --- a/src/Features/Core/Portable/InitializeParameter/AbstractAddParameterCheckCodeRefactoringProvider.cs +++ b/src/Features/Core/Portable/InitializeParameter/AbstractAddParameterCheckCodeRefactoringProvider.cs @@ -105,10 +105,10 @@ internal abstract partial class AbstractAddParameterCheckCodeRefactoringProvider foreach (var coalesceNode in syntax.DescendantNodes().OfType()) { var operation = GetOperation(semanticModel, coalesceNode, cancellationToken); - if (operation is INullCoalescingExpression coalesceExpression) + if (operation is ICoalesceExpression coalesceExpression) { - if (IsParameterReference(coalesceExpression.PrimaryOperand, parameter) && - syntaxFacts.IsThrowExpression(coalesceExpression.SecondaryOperand.Syntax)) + if (IsParameterReference(coalesceExpression.Expression, parameter) && + syntaxFacts.IsThrowExpression(coalesceExpression.WhenNull.Syntax)) { return true; } diff --git a/src/Features/Core/Portable/InitializeParameter/AbstractInitializeMemberFromParameterCodeRefactoringProviderMemberCreation.cs b/src/Features/Core/Portable/InitializeParameter/AbstractInitializeMemberFromParameterCodeRefactoringProviderMemberCreation.cs index a66107af87256531090802679454f757ad64eea9..8c74a89e48d9edeb0decf72098c17c9653664419 100644 --- a/src/Features/Core/Portable/InitializeParameter/AbstractInitializeMemberFromParameterCodeRefactoringProviderMemberCreation.cs +++ b/src/Features/Core/Portable/InitializeParameter/AbstractInitializeMemberFromParameterCodeRefactoringProviderMemberCreation.cs @@ -391,8 +391,8 @@ private IOperation TryFindFieldOrPropertyAssignmentStatement(IParameterSymbol pa return true; } - if (UnwrapImplicitConversion(assignmentExpression.Value) is INullCoalescingExpression coalesceExpression && - IsParameterReference(coalesceExpression.PrimaryOperand, parameter)) + if (UnwrapImplicitConversion(assignmentExpression.Value) is ICoalesceExpression coalesceExpression && + IsParameterReference(coalesceExpression.Expression, parameter)) { // We already have a member initialized with this parameter like: // this.field = parameter ?? ... diff --git a/src/Test/Utilities/Portable/Compilation/OperationTreeVerifier.cs b/src/Test/Utilities/Portable/Compilation/OperationTreeVerifier.cs index 25ba77ef569b7dff2cb075361e317fca105b6594..5fbb7620ebbb103686edf8bded9e4b2eab61a900 100644 --- a/src/Test/Utilities/Portable/Compilation/OperationTreeVerifier.cs +++ b/src/Test/Utilities/Portable/Compilation/OperationTreeVerifier.cs @@ -865,13 +865,13 @@ public override void VisitConditionalChoiceExpression(IConditionalChoiceExpressi Visit(operation.IfFalseValue, "IfFalse"); } - public override void VisitNullCoalescingExpression(INullCoalescingExpression operation) + public override void VisitCoalesceExpression(ICoalesceExpression operation) { - LogString(nameof(INullCoalescingExpression)); + LogString(nameof(ICoalesceExpression)); LogCommonPropertiesAndNewLine(operation); - Visit(operation.PrimaryOperand, "Left"); - Visit(operation.SecondaryOperand, "Right"); + Visit(operation.Expression, "Expression"); + Visit(operation.WhenNull, "WhenNull"); } public override void VisitIsTypeExpression(IIsTypeExpression operation) diff --git a/src/Test/Utilities/Portable/Compilation/TestOperationWalker.cs b/src/Test/Utilities/Portable/Compilation/TestOperationWalker.cs index ae9cdd4978e9c2e2d9da3ac0a9a67ee7539f0fb4..31dfefd8af814f137c8a5ab2fd1dd45c09c130aa 100644 --- a/src/Test/Utilities/Portable/Compilation/TestOperationWalker.cs +++ b/src/Test/Utilities/Portable/Compilation/TestOperationWalker.cs @@ -372,9 +372,9 @@ public override void VisitConditionalChoiceExpression(IConditionalChoiceExpressi base.VisitConditionalChoiceExpression(operation); } - public override void VisitNullCoalescingExpression(INullCoalescingExpression operation) + public override void VisitCoalesceExpression(ICoalesceExpression operation) { - base.VisitNullCoalescingExpression(operation); + base.VisitCoalesceExpression(operation); } public override void VisitIsTypeExpression(IIsTypeExpression operation)