提交 41574d3a 编写于 作者: F Fred Silberberg 提交者: GitHub

Merge pull request #21458 from 333fred/inullcoalescingexpression-refactor

Refactors INullCoalescingExpression to ICoalesce expression, and prop…
......@@ -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<IOperation> primaryOperand = new Lazy<IOperation>(() => Create(boundNullCoalescingOperator.LeftOperand));
Lazy<IOperation> secondaryOperand = new Lazy<IOperation>(() => Create(boundNullCoalescingOperator.RightOperand));
Lazy<IOperation> expression = new Lazy<IOperation>(() => Create(boundNullCoalescingOperator.LeftOperand));
Lazy<IOperation> whenNull = new Lazy<IOperation>(() => Create(boundNullCoalescingOperator.RightOperand));
SyntaxNode syntax = boundNullCoalescingOperator.Syntax;
ITypeSymbol type = boundNullCoalescingOperator.Type;
Optional<object> 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)
......
......@@ -318,11 +318,11 @@ static void Main(string[] args)
IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'object /*<b ... *</bind>*/;')
IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'object /*<b ... *</bind>*/;')
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);
}
......
......@@ -3039,74 +3039,74 @@ internal sealed partial class LazyMethodBindingExpression : BaseMethodBindingExp
/// <summary>
/// Represents a null-coalescing expression.
/// </summary>
internal abstract partial class BaseNullCoalescingExpression : Operation, INullCoalescingExpression
internal abstract partial class BaseCoalesceExpression : Operation, ICoalesceExpression
{
protected BaseNullCoalescingExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(OperationKind.NullCoalescingExpression, semanticModel, syntax, type, constantValue, isImplicit)
protected BaseCoalesceExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> 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<IOperation> Children
{
get
{
yield return PrimaryOperand;
yield return SecondaryOperand;
yield return Expression;
yield return WhenNull;
}
}
/// <summary>
/// Value to be unconditionally evaluated.
/// </summary>
public IOperation PrimaryOperand => Operation.SetParentOperation(PrimaryOperandImpl, this);
public IOperation Expression => Operation.SetParentOperation(ExpressionImpl, this);
/// <summary>
/// Value to be evaluated if Primary evaluates to null/Nothing.
/// Value to be evaluated if <see cref="Expression"/> evaluates to null/Nothing.
/// </summary>
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<TArgument, TResult>(OperationVisitor<TArgument, TResult> visitor, TArgument argument)
{
return visitor.VisitNullCoalescingExpression(this, argument);
return visitor.VisitCoalesceExpression(this, argument);
}
}
/// <summary>
/// Represents a null-coalescing expression.
/// </summary>
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<object> constantValue, bool isImplicit) :
public CoalesceExpression(IOperation expression, IOperation whenNull, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> 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; }
}
/// <summary>
/// Represents a null-coalescing expression.
/// </summary>
internal sealed partial class LazyNullCoalescingExpression : BaseNullCoalescingExpression, INullCoalescingExpression
internal sealed partial class LazyCoalesceExpression : BaseCoalesceExpression, ICoalesceExpression
{
private readonly Lazy<IOperation> _lazyPrimaryOperand;
private readonly Lazy<IOperation> _lazySecondaryOperand;
private readonly Lazy<IOperation> _lazyExpression;
private readonly Lazy<IOperation> _lazyWhenNull;
public LazyNullCoalescingExpression(Lazy<IOperation> primaryOperand, Lazy<IOperation> secondaryOperand, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit)
public LazyCoalesceExpression(Lazy<IOperation> expression, Lazy<IOperation> whenNull, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> 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;
}
/// <summary>
......
......@@ -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.
/// </remarks>
public interface INullCoalescingExpression : IOperation
public interface ICoalesceExpression : IOperation
{
/// <summary>
/// Value to be unconditionally evaluated.
/// </summary>
IOperation PrimaryOperand { get; }
IOperation Expression { get; }
/// <summary>
/// Value to be evaluated if Primary evaluates to null/Nothing.
/// Value to be evaluated if <see cref="Expression"/> evaluates to null/Nothing.
/// </summary>
IOperation SecondaryOperand { get; }
IOperation WhenNull { get; }
}
}
......@@ -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)
......
......@@ -96,8 +96,8 @@ public enum OperationKind
BinaryOperatorExpression = 0x10e,
/// <summary>Indicates an <see cref="IConditionalChoiceExpression"/>.</summary>
ConditionalChoiceExpression = 0x10f,
/// <summary>Indicates an <see cref="INullCoalescingExpression"/>.</summary>
NullCoalescingExpression = 0x110,
/// <summary>Indicates an <see cref="ICoalesceExpression"/>.</summary>
CoalesceExpression = 0x110,
/// <summary>Indicates an <see cref="ILambdaExpression"/>.</summary>
LambdaExpression = 0x111,
/// <summary>Indicates an <see cref="IObjectCreationExpression"/>.</summary>
......
......@@ -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);
}
......
......@@ -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<TArgument, TResult>.Vi
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitMemberInitializerExpression(Microsoft.CodeAnalysis.Semantics.IMemberInitializerExpression operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitMethodBindingExpression(Microsoft.CodeAnalysis.Semantics.IMethodBindingExpression operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitNameOfExpression(Microsoft.CodeAnalysis.Semantics.INameOfExpression operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitNullCoalescingExpression(Microsoft.CodeAnalysis.Semantics.INullCoalescingExpression operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitCoalesceExpression(Microsoft.CodeAnalysis.Semantics.ICoalesceExpression operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitObjectCreationExpression(Microsoft.CodeAnalysis.Semantics.IObjectCreationExpression operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitObjectOrCollectionInitializerExpression(Microsoft.CodeAnalysis.Semantics.IObjectOrCollectionInitializerExpression operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitOmittedArgumentExpression(Microsoft.CodeAnalysis.Semantics.IOmittedArgumentExpression operation, TArgument argument) -> TResult
......
......@@ -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
......
......@@ -105,10 +105,10 @@ internal abstract partial class AbstractAddParameterCheckCodeRefactoringProvider
foreach (var coalesceNode in syntax.DescendantNodes().OfType<TBinaryExpressionSyntax>())
{
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;
}
......
......@@ -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 ?? ...
......
......@@ -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)
......
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册