From 68bb9579232f74b775c1e9516b129ceeeb7df455 Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Fri, 11 Aug 2017 14:01:46 -0700 Subject: [PATCH 1/2] Refactors INullCoalescingExpression to ICoalesce expression, and properties to sensible names. --- .../Operations/CSharpOperationFactory.cs | 8 +-- .../IOperationTests_IConversionExpression.cs | 8 +-- .../Generated/Operations.xml.Generated.cs | 52 +++++++++---------- ...ngExpression.cs => ICoalesceExpression.cs} | 8 +-- .../Portable/Operations/OperationCloner.cs | 4 +- .../Core/Portable/Operations/OperationKind.cs | 4 +- .../Portable/Operations/OperationVisitor.cs | 4 +- .../Core/Portable/PublicAPI.Unshipped.txt | 12 ++--- .../Operations/VisualBasicOperationFactory.vb | 8 +-- ...ddParameterCheckCodeRefactoringProvider.cs | 6 +-- ...erCodeRefactoringProviderMemberCreation.cs | 4 +- .../Compilation/OperationTreeVerifier.cs | 8 +-- .../Compilation/TestOperationWalker.cs | 4 +- 13 files changed, 65 insertions(+), 65 deletions(-) rename src/Compilers/Core/Portable/Operations/{INullCoalescingExpression.cs => ICoalesceExpression.cs} (75%) diff --git a/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs b/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs index bd1721ce525c0..208325726c44d 100644 --- a/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs +++ b/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs @@ -869,14 +869,14 @@ private IConditionalChoiceExpression CreateBoundConditionalOperatorOperation(Bou return new LazyConditionalChoiceExpression(condition, ifTrueValue, ifFalseValue, _semanticModel, syntax, type, constantValue); } - 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); - return new LazyNullCoalescingExpression(primaryOperand, secondaryOperand, _semanticModel, syntax, type, constantValue); + return new LazyCoalesceExpression(expression, whenNull, _semanticModel, syntax, type, constantValue); } 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 3f9ef82c381f6..826c3e22ec371 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 2db8a93319f5b..b2b3debc8adb9 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 @@ public LazyMethodBindingExpression(IMethodSymbol method, bool isVirtual, Lazy /// 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) : - base(OperationKind.NullCoalescingExpression, semanticModel, syntax, type, constantValue) + protected BaseCoalesceExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(OperationKind.CoalesceExpression, semanticModel, syntax, type, constantValue) { } - 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) : + public CoalesceExpression(IOperation expression, IOperation whenNull, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(semanticModel, syntax, type, constantValue) { - 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) : base(semanticModel, syntax, type, constantValue) + public LazyCoalesceExpression(Lazy expression, Lazy whenNull, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(semanticModel, syntax, type, constantValue) { - _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 9f64b19bf8df0..197933ede9db0 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 038de6c65fd1c..29ff7552bbcef 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); } - 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); + return new CoalesceExpression(Visit(operation.Expression), Visit(operation.WhenNull), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); } 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 f0a17227330cd..5023d3c517a72 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 56c1f3b4db093..65d6ffdf9c4ba 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 a9d2055d6d0f1..a8b3b08991570 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 @@ -827,7 +827,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 @@ -917,7 +917,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 8eed84d14b050..a82baea454099 100644 --- a/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb +++ b/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb @@ -443,13 +443,13 @@ Namespace Microsoft.CodeAnalysis.Semantics Return New LazyBinaryOperatorExpression(binaryOperationKind, leftOperand, rightOperand, isLifted, usesOperatorMethod, operatorMethod, _semanticModel, syntax, type, constantValue) 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) - Return New LazyNullCoalescingExpression(primaryOperand, secondaryOperand, _semanticModel, syntax, type, constantValue) + Return New LazyCoalesceExpression(expression, whenNull, _semanticModel, syntax, type, constantValue) End Function Private Function CreateBoundUserDefinedShortCircuitingOperatorOperation(boundUserDefinedShortCircuitingOperator As BoundUserDefinedShortCircuitingOperator) As IBinaryOperatorExpression diff --git a/src/Features/Core/Portable/InitializeParameter/AbstractAddParameterCheckCodeRefactoringProvider.cs b/src/Features/Core/Portable/InitializeParameter/AbstractAddParameterCheckCodeRefactoringProvider.cs index cbc58c586469f..86c89802aaae2 100644 --- a/src/Features/Core/Portable/InitializeParameter/AbstractAddParameterCheckCodeRefactoringProvider.cs +++ b/src/Features/Core/Portable/InitializeParameter/AbstractAddParameterCheckCodeRefactoringProvider.cs @@ -105,10 +105,10 @@ private bool ContainsNullCoalesceCheck( 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 a66107af87256..8c74a89e48d9e 100644 --- a/src/Features/Core/Portable/InitializeParameter/AbstractInitializeMemberFromParameterCodeRefactoringProviderMemberCreation.cs +++ b/src/Features/Core/Portable/InitializeParameter/AbstractInitializeMemberFromParameterCodeRefactoringProviderMemberCreation.cs @@ -391,8 +391,8 @@ private static bool IsParameterReferenceOrCoalesceOfParameterReference( 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 25ba77ef569b7..5fbb7620ebbb1 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 ae9cdd4978e9c..31dfefd8af814 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) From ad58d125e2b579f8789305b0259b992a8af24bcd Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Tue, 15 Aug 2017 11:16:46 -0700 Subject: [PATCH 2/2] Fixed unintentional capitalization change. --- .../Operations/VisualBasicOperationFactory.vb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb b/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb index bdbc96ea52edf..64f079c606814 100644 --- a/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb +++ b/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb @@ -286,7 +286,7 @@ Namespace Microsoft.CodeAnalysis.Semantics End Function Private Function CreateBoundMeReferenceOperation(boundMeReference As BoundMeReference) As IInstanceReferenceExpression - Dim instanceReferenceKind As InstanceReferenceKind = If(boundMeReference.WasCompilerGenerated, instanceReferenceKind.Implicit, instanceReferenceKind.Explicit) + Dim instanceReferenceKind As InstanceReferenceKind = If(boundMeReference.WasCompilerGenerated, InstanceReferenceKind.Implicit, InstanceReferenceKind.Explicit) Dim syntax As SyntaxNode = boundMeReference.Syntax Dim type As ITypeSymbol = boundMeReference.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundMeReference.ConstantValueOpt) @@ -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) @@ -471,7 +471,7 @@ Namespace Microsoft.CodeAnalysis.Semantics 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 @@ -1073,7 +1073,7 @@ Namespace Microsoft.CodeAnalysis.Semantics Private Function CreateBoundGotoStatementOperation(boundGotoStatement As BoundGotoStatement) As IBranchStatement Dim target As ILabelSymbol = boundGotoStatement.Label - Dim branchKind As BranchKind = branchKind.GoTo + Dim branchKind As BranchKind = BranchKind.GoTo Dim syntax As SyntaxNode = boundGotoStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() @@ -1083,7 +1083,7 @@ Namespace Microsoft.CodeAnalysis.Semantics Private Function CreateBoundContinueStatementOperation(boundContinueStatement As BoundContinueStatement) As IBranchStatement Dim target As ILabelSymbol = boundContinueStatement.Label - Dim branchKind As BranchKind = branchKind.Continue + Dim branchKind As BranchKind = BranchKind.Continue Dim syntax As SyntaxNode = boundContinueStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() @@ -1093,7 +1093,7 @@ Namespace Microsoft.CodeAnalysis.Semantics Private Function CreateBoundExitStatementOperation(boundExitStatement As BoundExitStatement) As IBranchStatement Dim target As ILabelSymbol = boundExitStatement.Label - Dim branchKind As BranchKind = branchKind.Break + Dim branchKind As BranchKind = BranchKind.Break Dim syntax As SyntaxNode = boundExitStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)()