提交 c0d12282 编写于 作者: M Manish Vasani

Address PR feedback and add more unit tests

上级 30167a69
......@@ -243,7 +243,7 @@ internal static UnaryOperatorKind DeriveUnaryOperatorKind(CSharp.UnaryOperatorKi
return UnaryOperatorKind.Minus;
case CSharp.UnaryOperatorKind.LogicalNegation:
return UnaryOperatorKind.LogicalNot;
return UnaryOperatorKind.Not;
case CSharp.UnaryOperatorKind.BitwiseComplement:
return UnaryOperatorKind.BitwiseNegation;
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Test.Utilities;
......@@ -474,7 +474,7 @@ static void Main()
Variables: Local_1: System.Boolean b
Initializer: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Boolean) (Syntax: '!x.Equals(null)')
Conversion: CommonConversion (Exists: True, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
Operand: IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot) (OperationKind.UnaryOperatorExpression, Type: System.Object) (Syntax: '!x.Equals(null)')
Operand: IUnaryOperatorExpression (UnaryOperatorKind.Not) (OperationKind.UnaryOperatorExpression, Type: System.Object) (Syntax: '!x.Equals(null)')
Operand: IInvocationExpression ( ? C.()) (OperationKind.InvocationExpression, Type: ?) (Syntax: 'x.Equals(null)')
Instance Receiver: IOperation: (OperationKind.None) (Syntax: 'x.Equals')
Arguments(1):
......
......@@ -1357,7 +1357,7 @@ System.Boolean Method()
";
string expectedOperationTree = @"
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot) (OperationKind.UnaryOperatorExpression, Type: System.Boolean) (Syntax: '!i')
IUnaryOperatorExpression (UnaryOperatorKind.Not) (OperationKind.UnaryOperatorExpression, Type: System.Boolean) (Syntax: '!i')
Operand: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Boolean) (Syntax: 'i')
";
VerifyOperationTreeForTest<PrefixUnaryExpressionSyntax>(source, expectedOperationTree);
......@@ -1379,7 +1379,7 @@ System.Boolean Method()
";
string expectedOperationTree = @"
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot) (OperationKind.UnaryOperatorExpression, Type: System.Boolean) (Syntax: '!Method()')
IUnaryOperatorExpression (UnaryOperatorKind.Not) (OperationKind.UnaryOperatorExpression, Type: System.Boolean) (Syntax: '!Method()')
Operand: IInvocationExpression ( System.Boolean A.Method()) (OperationKind.InvocationExpression, Type: System.Boolean) (Syntax: 'Method()')
Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Implicit) (OperationKind.InstanceReferenceExpression, Type: A) (Syntax: 'Method')
Arguments(0)
......@@ -2133,7 +2133,7 @@ dynamic Method()
";
string expectedOperationTree = @"
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot) (OperationKind.UnaryOperatorExpression, Type: dynamic) (Syntax: '!i')
IUnaryOperatorExpression (UnaryOperatorKind.Not) (OperationKind.UnaryOperatorExpression, Type: dynamic) (Syntax: '!i')
Operand: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: dynamic) (Syntax: 'i')
";
VerifyOperationTreeForTest<PrefixUnaryExpressionSyntax>(source, expectedOperationTree);
......@@ -2227,7 +2227,7 @@ dynamic Method()
";
string expectedOperationTree = @"
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot) (OperationKind.UnaryOperatorExpression, Type: dynamic) (Syntax: '!Method()')
IUnaryOperatorExpression (UnaryOperatorKind.Not) (OperationKind.UnaryOperatorExpression, Type: dynamic) (Syntax: '!Method()')
Operand: IInvocationExpression ( dynamic A.Method()) (OperationKind.InvocationExpression, Type: dynamic) (Syntax: 'Method()')
Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Implicit) (OperationKind.InstanceReferenceExpression, Type: A) (Syntax: 'Method')
Arguments(0)
......@@ -2527,7 +2527,7 @@ public struct CustomType
}
";
string expectedOperationTree = @"
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot) (OperatorMethod: CustomType CustomType.op_LogicalNot(CustomType x)) (OperationKind.UnaryOperatorExpression, Type: CustomType) (Syntax: '!i')
IUnaryOperatorExpression (UnaryOperatorKind.Not) (OperatorMethod: CustomType CustomType.op_LogicalNot(CustomType x)) (OperationKind.UnaryOperatorExpression, Type: CustomType) (Syntax: '!i')
Operand: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: CustomType) (Syntax: 'i')
";
VerifyOperationTreeForTest<PrefixUnaryExpressionSyntax>(source, expectedOperationTree);
......@@ -2693,7 +2693,7 @@ public struct CustomType
}
";
string expectedOperationTree = @"
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot) (OperatorMethod: CustomType CustomType.op_LogicalNot(CustomType x)) (OperationKind.UnaryOperatorExpression, Type: CustomType) (Syntax: '!Method()')
IUnaryOperatorExpression (UnaryOperatorKind.Not) (OperatorMethod: CustomType CustomType.op_LogicalNot(CustomType x)) (OperationKind.UnaryOperatorExpression, Type: CustomType) (Syntax: '!Method()')
Operand: IInvocationExpression ( CustomType A.Method()) (OperationKind.InvocationExpression, Type: CustomType) (Syntax: 'Method()')
Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Implicit) (OperationKind.InstanceReferenceExpression, Type: A) (Syntax: 'Method')
Arguments(0)
......
......@@ -17,7 +17,7 @@ public enum UnaryOperatorKind
/// <summary>
/// Represents the C# '!' operator and VB 'Not' operator.
/// </summary>
LogicalNot = 0x2,
Not = 0x2,
/// <summary>
/// Represents the unary '+' operator.
......
......@@ -484,7 +484,7 @@ Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.BitwiseNegation = 1 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.False = 6 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.Invalid = 255 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.LogicalNot = 2 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.Not = 2 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.Minus = 4 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.None = 0 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind.Plus = 3 -> Microsoft.CodeAnalysis.Semantics.UnaryOperatorKind
......
......@@ -275,7 +275,7 @@ Namespace Microsoft.CodeAnalysis.Semantics
Dim type As ITypeSymbol = boundAssignmentOperator.Type
Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundAssignmentOperator.ConstantValueOpt)
Dim isLifted As Boolean = boundAssignmentOperator.Type.IsNullableType()
Dim isChecked As Boolean = False
Dim isChecked As Boolean = temporaryRight.IsChecked
Return New LazyCompoundAssignmentExpression(operatorKind, isLifted, isChecked, target, value, usesOperatorMethod, operatorMethod, _semanticModel, syntax, type, constantValue, isImplicit)
Else
Dim target As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() Create(boundAssignmentOperator.Left))
......
......@@ -456,7 +456,7 @@ Namespace Microsoft.CodeAnalysis.Semantics
Case VisualBasic.UnaryOperatorKind.Minus
Return UnaryOperatorKind.Minus
Case VisualBasic.UnaryOperatorKind.Not
Return UnaryOperatorKind.LogicalNot
Return UnaryOperatorKind.Not
Case VisualBasic.UnaryOperatorKind.IsTrue
Return UnaryOperatorKind.True
Case VisualBasic.UnaryOperatorKind.IsFalse
......@@ -499,9 +499,9 @@ Namespace Microsoft.CodeAnalysis.Semantics
Case VisualBasic.BinaryOperatorKind.LessThanOrEqual
Return BinaryOperatorKind.LessThanOrEqual
Case VisualBasic.BinaryOperatorKind.Equals
Return If(leftOpt?.Type.SpecialType = SpecialType.System_Object, BinaryOperatorKind.ObjectValueEquals, BinaryOperatorKind.Equals)
Return If(leftOpt?.Type?.SpecialType = SpecialType.System_Object, BinaryOperatorKind.ObjectValueEquals, BinaryOperatorKind.Equals)
Case VisualBasic.BinaryOperatorKind.NotEquals
Return If(leftOpt?.Type.SpecialType = SpecialType.System_Object, BinaryOperatorKind.ObjectValueNotEquals, BinaryOperatorKind.NotEquals)
Return If(leftOpt?.Type?.SpecialType = SpecialType.System_Object, BinaryOperatorKind.ObjectValueNotEquals, BinaryOperatorKind.NotEquals)
Case VisualBasic.BinaryOperatorKind.Is
Return BinaryOperatorKind.Equals
Case VisualBasic.BinaryOperatorKind.IsNot
......
......@@ -188,7 +188,7 @@ End Module
comp.VerifyOperationTree(nodes(0), expectedOperationTree:="
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'x += y')
Expression: ICompoundAssignmentExpression (BinaryOperatorKind.Add) (OperationKind.CompoundAssignmentExpression, Type: System.Int32) (Syntax: 'x += y')
Expression: ICompoundAssignmentExpression (BinaryOperatorKind.Add, Checked) (OperationKind.CompoundAssignmentExpression, Type: System.Int32) (Syntax: 'x += y')
Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'x')
Right: ILocalReferenceExpression: y (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'y')
")
......@@ -214,7 +214,7 @@ IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'x += y')
comp.VerifyOperationTree(nodes(1), expectedOperationTree:="
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'a += b')
Expression: ICompoundAssignmentExpression (BinaryOperatorKind.Add) (OperatorMethod: Function B2.op_Addition(x As B2, y As B2) As B2) (OperationKind.CompoundAssignmentExpression, Type: B2) (Syntax: 'a += b')
Expression: ICompoundAssignmentExpression (BinaryOperatorKind.Add, Checked) (OperatorMethod: Function B2.op_Addition(x As B2, y As B2) As B2) (OperationKind.CompoundAssignmentExpression, Type: B2) (Syntax: 'a += b')
Left: ILocalReferenceExpression: a (OperationKind.LocalReferenceExpression, Type: B2) (Syntax: 'a')
Right: ILocalReferenceExpression: b (OperationKind.LocalReferenceExpression, Type: B2) (Syntax: 'b')
")
......
......@@ -790,6 +790,217 @@ IBlockStatement (10 statements) (OperationKind.BlockStatement) (Syntax: 'Sub M(x
VerifyOperationTreeAndDiagnosticsForTest(Of MethodBlockSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub
<CompilerTrait(CompilerFeature.IOperation)>
<Fact>
Public Sub TestBinaryCompoundOperators()
Dim source = <![CDATA[
Module Module1
Sub Main()'BIND:"Sub Main()"
Dim x, y As New Integer
x += y
x -= y
x *= y
x /= y
x \= y
x ^= y
x &= y
x <<= 2
x >>= 3
End Sub
End Module]]>.Value
' We don't seem to be detecting "x ^= y" and "x &= y" as compound operator expressions.
' See https://github.com/dotnet/roslyn/issues/21738
Dim expectedOperationTree = <![CDATA[
IBlockStatement (12 statements, 2 locals) (OperationKind.BlockStatement) (Syntax: 'Sub Main()' ... End Sub')
Locals: Local_1: x As System.Int32
Local_2: y As System.Int32
IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'Dim x, y As New Integer')
IVariableDeclaration (2 variables) (OperationKind.VariableDeclaration) (Syntax: 'x, y As New Integer')
Variables: Local_1: x As System.Int32
Local_2: y As System.Int32
Initializer: IObjectCreationExpression (Constructor: Sub System.Int32..ctor()) (OperationKind.ObjectCreationExpression, Type: System.Int32) (Syntax: 'New Integer')
Arguments(0)
Initializer: null
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'x += y')
Expression: ICompoundAssignmentExpression (BinaryOperatorKind.Add, Checked) (OperationKind.CompoundAssignmentExpression, Type: System.Int32) (Syntax: 'x += y')
Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'x')
Right: ILocalReferenceExpression: y (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'y')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'x -= y')
Expression: ICompoundAssignmentExpression (BinaryOperatorKind.Subtract, Checked) (OperationKind.CompoundAssignmentExpression, Type: System.Int32) (Syntax: 'x -= y')
Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'x')
Right: ILocalReferenceExpression: y (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'y')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'x *= y')
Expression: ICompoundAssignmentExpression (BinaryOperatorKind.Multiply, Checked) (OperationKind.CompoundAssignmentExpression, Type: System.Int32) (Syntax: 'x *= y')
Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'x')
Right: ILocalReferenceExpression: y (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'y')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'x /= y')
Expression: ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: 'x /= y')
Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'x')
Right: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Int32) (Syntax: 'x /= y')
Conversion: CommonConversion (Exists: False, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
Operand: IBinaryOperatorExpression (BinaryOperatorKind.Divide, Checked) (OperationKind.BinaryOperatorExpression, Type: System.Double) (Syntax: 'x /= y')
Left: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Double) (Syntax: 'x')
Conversion: CommonConversion (Exists: False, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
Operand: IOperation: (OperationKind.None) (Syntax: 'x')
Right: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Double) (Syntax: 'y')
Conversion: CommonConversion (Exists: False, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
Operand: ILocalReferenceExpression: y (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'y')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'x \= y')
Expression: ICompoundAssignmentExpression (BinaryOperatorKind.IntegerDivide, Checked) (OperationKind.CompoundAssignmentExpression, Type: System.Int32) (Syntax: 'x \= y')
Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'x')
Right: ILocalReferenceExpression: y (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'y')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'x ^= y')
Expression: ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: 'x ^= y')
Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'x')
Right: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Int32) (Syntax: 'x ^= y')
Conversion: CommonConversion (Exists: False, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
Operand: IBinaryOperatorExpression (BinaryOperatorKind.Power, Checked) (OperationKind.BinaryOperatorExpression, Type: System.Double) (Syntax: 'x ^= y')
Left: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Double) (Syntax: 'x')
Conversion: CommonConversion (Exists: False, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
Operand: IOperation: (OperationKind.None) (Syntax: 'x')
Right: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Double) (Syntax: 'y')
Conversion: CommonConversion (Exists: False, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
Operand: ILocalReferenceExpression: y (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'y')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'x &= y')
Expression: ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: 'x &= y')
Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'x')
Right: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Int32) (Syntax: 'x &= y')
Conversion: CommonConversion (Exists: False, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
Operand: IBinaryOperatorExpression (BinaryOperatorKind.Concatenate, Checked) (OperationKind.BinaryOperatorExpression, Type: System.String) (Syntax: 'x &= y')
Left: IConversionExpression (Explicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.String) (Syntax: 'x')
Conversion: CommonConversion (Exists: False, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
Operand: IOperation: (OperationKind.None) (Syntax: 'x')
Right: IConversionExpression (Explicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.String) (Syntax: 'y')
Conversion: CommonConversion (Exists: False, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
Operand: ILocalReferenceExpression: y (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'y')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'x <<= 2')
Expression: ICompoundAssignmentExpression (BinaryOperatorKind.LeftShift, Checked) (OperationKind.CompoundAssignmentExpression, Type: System.Int32) (Syntax: 'x <<= 2')
Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'x')
Right: ILiteralExpression (Text: 2) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 2) (Syntax: '2')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'x >>= 3')
Expression: ICompoundAssignmentExpression (BinaryOperatorKind.RightShift, Checked) (OperationKind.CompoundAssignmentExpression, Type: System.Int32) (Syntax: 'x >>= 3')
Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'x')
Right: ILiteralExpression (Text: 3) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 3) (Syntax: '3')
ILabelStatement (Label: exit) (OperationKind.LabelStatement) (Syntax: 'End Sub')
LabeledStatement: null
IReturnStatement (OperationKind.ReturnStatement) (Syntax: 'End Sub')
ReturnedValue: null
]]>.Value
Dim expectedDiagnostics = String.Empty
VerifyOperationTreeAndDiagnosticsForTest(Of MethodBlockSyntax)(source, expectedOperationTree, expectedDiagnostics)
End Sub
<CompilerTrait(CompilerFeature.IOperation)>
<Fact>
Public Sub TestBinaryCompoundOperators_Unchecked()
Dim source = <![CDATA[
Module Module1
Sub Main()'BIND:"Sub Main()"
Dim x, y As New Integer
x += y
x -= y
x *= y
x /= y
x \= y
x ^= y
x &= y
x <<= 2
x >>= 3
End Sub
End Module]]>.Value
Dim expectedOperationTree = <![CDATA[
IBlockStatement (12 statements, 2 locals) (OperationKind.BlockStatement) (Syntax: 'Sub Main()' ... End Sub')
Locals: Local_1: x As System.Int32
Local_2: y As System.Int32
IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'Dim x, y As New Integer')
IVariableDeclaration (2 variables) (OperationKind.VariableDeclaration) (Syntax: 'x, y As New Integer')
Variables: Local_1: x As System.Int32
Local_2: y As System.Int32
Initializer: IObjectCreationExpression (Constructor: Sub System.Int32..ctor()) (OperationKind.ObjectCreationExpression, Type: System.Int32) (Syntax: 'New Integer')
Arguments(0)
Initializer: null
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'x += y')
Expression: ICompoundAssignmentExpression (BinaryOperatorKind.Add) (OperationKind.CompoundAssignmentExpression, Type: System.Int32) (Syntax: 'x += y')
Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'x')
Right: ILocalReferenceExpression: y (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'y')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'x -= y')
Expression: ICompoundAssignmentExpression (BinaryOperatorKind.Subtract) (OperationKind.CompoundAssignmentExpression, Type: System.Int32) (Syntax: 'x -= y')
Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'x')
Right: ILocalReferenceExpression: y (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'y')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'x *= y')
Expression: ICompoundAssignmentExpression (BinaryOperatorKind.Multiply) (OperationKind.CompoundAssignmentExpression, Type: System.Int32) (Syntax: 'x *= y')
Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'x')
Right: ILocalReferenceExpression: y (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'y')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'x /= y')
Expression: ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: 'x /= y')
Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'x')
Right: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Int32) (Syntax: 'x /= y')
Conversion: CommonConversion (Exists: False, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
Operand: IBinaryOperatorExpression (BinaryOperatorKind.Divide) (OperationKind.BinaryOperatorExpression, Type: System.Double) (Syntax: 'x /= y')
Left: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Double) (Syntax: 'x')
Conversion: CommonConversion (Exists: False, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
Operand: IOperation: (OperationKind.None) (Syntax: 'x')
Right: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Double) (Syntax: 'y')
Conversion: CommonConversion (Exists: False, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
Operand: ILocalReferenceExpression: y (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'y')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'x \= y')
Expression: ICompoundAssignmentExpression (BinaryOperatorKind.IntegerDivide) (OperationKind.CompoundAssignmentExpression, Type: System.Int32) (Syntax: 'x \= y')
Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'x')
Right: ILocalReferenceExpression: y (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'y')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'x ^= y')
Expression: ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: 'x ^= y')
Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'x')
Right: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Int32) (Syntax: 'x ^= y')
Conversion: CommonConversion (Exists: False, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
Operand: IBinaryOperatorExpression (BinaryOperatorKind.Power) (OperationKind.BinaryOperatorExpression, Type: System.Double) (Syntax: 'x ^= y')
Left: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Double) (Syntax: 'x')
Conversion: CommonConversion (Exists: False, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
Operand: IOperation: (OperationKind.None) (Syntax: 'x')
Right: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Double) (Syntax: 'y')
Conversion: CommonConversion (Exists: False, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
Operand: ILocalReferenceExpression: y (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'y')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'x &= y')
Expression: ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: 'x &= y')
Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'x')
Right: IConversionExpression (Implicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.Int32) (Syntax: 'x &= y')
Conversion: CommonConversion (Exists: False, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
Operand: IBinaryOperatorExpression (BinaryOperatorKind.Concatenate) (OperationKind.BinaryOperatorExpression, Type: System.String) (Syntax: 'x &= y')
Left: IConversionExpression (Explicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.String) (Syntax: 'x')
Conversion: CommonConversion (Exists: False, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
Operand: IOperation: (OperationKind.None) (Syntax: 'x')
Right: IConversionExpression (Explicit, TryCast: False, Unchecked) (OperationKind.ConversionExpression, Type: System.String) (Syntax: 'y')
Conversion: CommonConversion (Exists: False, IsIdentity: False, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null)
Operand: ILocalReferenceExpression: y (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'y')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'x <<= 2')
Expression: ICompoundAssignmentExpression (BinaryOperatorKind.LeftShift) (OperationKind.CompoundAssignmentExpression, Type: System.Int32) (Syntax: 'x <<= 2')
Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'x')
Right: ILiteralExpression (Text: 2) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 2) (Syntax: '2')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'x >>= 3')
Expression: ICompoundAssignmentExpression (BinaryOperatorKind.RightShift) (OperationKind.CompoundAssignmentExpression, Type: System.Int32) (Syntax: 'x >>= 3')
Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'x')
Right: ILiteralExpression (Text: 3) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 3) (Syntax: '3')
ILabelStatement (Label: exit) (OperationKind.LabelStatement) (Syntax: 'End Sub')
LabeledStatement: null
IReturnStatement (OperationKind.ReturnStatement) (Syntax: 'End Sub')
ReturnedValue: null
]]>.Value
Dim expectedDiagnostics = String.Empty
Dim fileName = "a.vb"
Dim syntaxTree = Parse(source, fileName)
Dim references = DefaultVbReferences.Concat({ValueTupleRef, SystemRuntimeFacadeRef})
Dim compilation = CreateCompilationWithMscorlib45AndVBRuntime({syntaxTree}, references:=references, options:=TestOptions.ReleaseDll.WithOverflowChecks(False))
VerifyOperationTreeAndDiagnosticsForTest(Of MethodBlockSyntax)(compilation, fileName, expectedOperationTree, expectedDiagnostics)
End Sub
<CompilerTrait(CompilerFeature.IOperation)>
<Fact>
Public Sub TestUserDefinedBinaryOperators()
......
......@@ -23,7 +23,7 @@ Public Class MyClass1
End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
Dim expectedOperationTree = <![CDATA[
IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'For i As In ... Next')
Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThanOrEqual) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'myarray.Length - 1')
Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i As Integer')
......@@ -85,7 +85,7 @@ Public Class MyClass1
End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
Dim expectedOperationTree = <![CDATA[
IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'For i As In ... Next')
Condition: IConditionalExpression (OperationKind.ConditionalExpression, Type: System.Boolean) (Syntax: '"1"')
Condition: IBinaryOperatorExpression (BinaryOperatorKind.GreaterThanOrEqual) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 's')
......@@ -153,7 +153,7 @@ Public Class MyClass1
End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
Dim expectedOperationTree = <![CDATA[
IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'For i As Do ... Next')
Condition: IConditionalExpression (OperationKind.ConditionalExpression, Type: System.Boolean) (Syntax: '0')
Condition: IBinaryOperatorExpression (BinaryOperatorKind.GreaterThanOrEqual) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 's')
......@@ -220,7 +220,7 @@ Public Class MyClass1
End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
Dim expectedOperationTree = <![CDATA[
IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'For ctrlVar ... Next')
Condition: IConditionalExpression (OperationKind.ConditionalExpression, Type: System.Boolean) (Syntax: 'limit')
Condition: IBinaryOperatorExpression (BinaryOperatorKind.GreaterThanOrEqual) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'stp')
......@@ -285,7 +285,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
Dim expectedOperationTree = <![CDATA[
IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'For AVarNam ... xt AVarName')
Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThanOrEqual) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: '2')
Left: ILocalReferenceExpression: AVarName (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'AVarName')
......@@ -379,7 +379,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
Dim expectedOperationTree = <![CDATA[
IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'For I = 1 T ... Next')
Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThanOrEqual) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: '2')
Left: ILocalReferenceExpression: I (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'I')
......@@ -450,7 +450,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
Dim expectedOperationTree = <![CDATA[
IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'For I = 1 T ... Next')
Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThanOrEqual) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: '2')
Left: ILocalReferenceExpression: I (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'I')
......@@ -519,7 +519,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
Dim expectedOperationTree = <![CDATA[
IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'For I = 1 T ... Next')
Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThanOrEqual) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: '2')
Left: ILocalReferenceExpression: I (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'I')
......@@ -587,7 +587,7 @@ Enum e1
End Enum
]]>.Value
Dim expectedOperationTree = <![CDATA[
Dim expectedOperationTree = <![CDATA[
IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'For x As e1 ... Next')
Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThanOrEqual) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'e1.c')
Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: e1) (Syntax: 'x As e1')
......@@ -635,7 +635,7 @@ Public Class MyClass1
End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
Dim expectedOperationTree = <![CDATA[
IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'For i As In ... Next')
Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThanOrEqual) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: '30')
Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i As Integer')
......@@ -687,7 +687,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
Dim expectedOperationTree = <![CDATA[
IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'For global_ ... Next')
Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThanOrEqual) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: '10')
Left: ILocalReferenceExpression: global_x (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'global_x As Integer')
......@@ -726,7 +726,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
Dim expectedOperationTree = <![CDATA[
IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'For x As In ... o 10 : Next')
Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThanOrEqual) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: '10')
Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'x As Integer')
......@@ -766,7 +766,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
Dim expectedOperationTree = <![CDATA[
IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'For Y = 1 T ... Next')
Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThanOrEqual) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: '2')
Left: ILocalReferenceExpression: Y (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'Y')
......@@ -811,7 +811,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
Dim expectedOperationTree = <![CDATA[
IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'For element ... Next')
Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThanOrEqual) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: '42')
Left: ILocalReferenceExpression: element1 (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'element1')
......@@ -856,7 +856,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
Dim expectedOperationTree = <![CDATA[
IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'For i As In ... Next')
Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThanOrEqual) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: '5')
Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i As Integer')
......@@ -907,7 +907,7 @@ End Module
]]>.Value
Dim expectedOperationTree = <![CDATA[
Dim expectedOperationTree = <![CDATA[
IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'For X = 10 ... Next')
Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThanOrEqual) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: '0')
Left: IFieldReferenceExpression: M.X As System.Int32 (Static) (OperationKind.FieldReferenceExpression, Type: System.Int32) (Syntax: 'X')
......@@ -954,7 +954,7 @@ End Module
]]>.Value
Dim expectedOperationTree = <![CDATA[
Dim expectedOperationTree = <![CDATA[
IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement, IsInvalid) (Syntax: 'For X = 10 ... Next')
Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThanOrEqual) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: '0')
Left: IFieldReferenceExpression: M.X As System.String (Static) (OperationKind.FieldReferenceExpression, Type: System.String, IsInvalid) (Syntax: 'X')
......@@ -998,7 +998,7 @@ Module Program
End Sub
End Module]]>.Value
Dim expectedOperationTree = <![CDATA[
Dim expectedOperationTree = <![CDATA[
IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'For A = 1 T ... Next B, A')
Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThanOrEqual) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: '2')
Left: ILocalReferenceExpression: A (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'A')
......@@ -1054,7 +1054,7 @@ Structure C
End Structure
]]>.Value
Dim expectedOperationTree = <![CDATA[
Dim expectedOperationTree = <![CDATA[
IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'For x = 12 ... Next')
Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThanOrEqual) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'y')
Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'x')
......@@ -1095,7 +1095,7 @@ Structure C
End Structure
]]>.Value
Dim expectedOperationTree = <![CDATA[
Dim expectedOperationTree = <![CDATA[
IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'For x = 12 ... Next')
Condition: IConditionalExpression (OperationKind.ConditionalExpression, Type: System.Boolean) (Syntax: 'y')
Condition: IBinaryOperatorExpression (BinaryOperatorKind.GreaterThanOrEqual, IsLifted) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'For x = 12 ... Next')
......@@ -1151,7 +1151,7 @@ Structure C
End Structure
]]>.Value
Dim expectedOperationTree = <![CDATA[
Dim expectedOperationTree = <![CDATA[
IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'For x = 12 ... Next')
Condition: IBinaryOperatorExpression (BinaryOperatorKind.LessThanOrEqual) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'y')
Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'x')
......@@ -1194,7 +1194,7 @@ Structure C
End Structure
]]>.Value
Dim expectedOperationTree = <![CDATA[
Dim expectedOperationTree = <![CDATA[
IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'For x = 12 ... Next')
Condition: IConditionalExpression (OperationKind.ConditionalExpression, Type: System.Boolean) (Syntax: 'y')
Condition: IBinaryOperatorExpression (BinaryOperatorKind.GreaterThanOrEqual, IsLifted) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'For x = 12 ... Next')
......@@ -1249,7 +1249,7 @@ Structure C
End Structure
]]>.Value
Dim expectedOperationTree = <![CDATA[
Dim expectedOperationTree = <![CDATA[
IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'For x = 12 ... Next')
Condition: IConditionalExpression (OperationKind.ConditionalExpression, Type: System.Boolean) (Syntax: 'y')
Condition: IBinaryOperatorExpression (BinaryOperatorKind.GreaterThanOrEqual) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 's')
......@@ -1302,7 +1302,7 @@ Structure C
End Structure
]]>.Value
Dim expectedOperationTree = <![CDATA[
Dim expectedOperationTree = <![CDATA[
IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'For x = 12 ... Next')
Condition: IConditionalExpression (OperationKind.ConditionalExpression, Type: System.Boolean) (Syntax: 'y')
Condition: IBinaryOperatorExpression (BinaryOperatorKind.GreaterThanOrEqual, IsLifted) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 's')
......@@ -1357,7 +1357,7 @@ Structure C
End Structure
]]>.Value
Dim expectedOperationTree = <![CDATA[
Dim expectedOperationTree = <![CDATA[
IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'For x = 12 ... Next')
Condition: IConditionalExpression (OperationKind.ConditionalExpression, Type: System.Boolean) (Syntax: 'y')
Condition: IBinaryOperatorExpression (BinaryOperatorKind.GreaterThanOrEqual) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 's')
......@@ -1412,7 +1412,7 @@ Structure C
End Structure
]]>.Value
Dim expectedOperationTree = <![CDATA[
Dim expectedOperationTree = <![CDATA[
IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'For x = 12 ... Next')
Condition: IConditionalExpression (OperationKind.ConditionalExpression, Type: System.Boolean) (Syntax: 'y')
Condition: IBinaryOperatorExpression (BinaryOperatorKind.GreaterThanOrEqual, IsLifted) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 's')
......
......@@ -443,7 +443,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot, Checked) (OperationKind.UnaryOperatorExpression, Type: System.SByte) (Syntax: 'Not i')
IUnaryOperatorExpression (UnaryOperatorKind.Not, Checked) (OperationKind.UnaryOperatorExpression, Type: System.SByte) (Syntax: 'Not i')
Operand: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.SByte) (Syntax: 'i')
]]>.Value
......@@ -464,7 +464,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot, Checked) (OperationKind.UnaryOperatorExpression, Type: System.Byte) (Syntax: 'Not i')
IUnaryOperatorExpression (UnaryOperatorKind.Not, Checked) (OperationKind.UnaryOperatorExpression, Type: System.Byte) (Syntax: 'Not i')
Operand: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Byte) (Syntax: 'i')
]]>.Value
......@@ -485,7 +485,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot, Checked) (OperationKind.UnaryOperatorExpression, Type: System.Int16) (Syntax: 'Not i')
IUnaryOperatorExpression (UnaryOperatorKind.Not, Checked) (OperationKind.UnaryOperatorExpression, Type: System.Int16) (Syntax: 'Not i')
Operand: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int16) (Syntax: 'i')
]]>.Value
......@@ -506,7 +506,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot, Checked) (OperationKind.UnaryOperatorExpression, Type: System.UInt16) (Syntax: 'Not i')
IUnaryOperatorExpression (UnaryOperatorKind.Not, Checked) (OperationKind.UnaryOperatorExpression, Type: System.UInt16) (Syntax: 'Not i')
Operand: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.UInt16) (Syntax: 'i')
]]>.Value
......@@ -527,7 +527,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot, Checked) (OperationKind.UnaryOperatorExpression, Type: System.Int32) (Syntax: 'Not i')
IUnaryOperatorExpression (UnaryOperatorKind.Not, Checked) (OperationKind.UnaryOperatorExpression, Type: System.Int32) (Syntax: 'Not i')
Operand: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i')
]]>.Value
......@@ -548,7 +548,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot, Checked) (OperationKind.UnaryOperatorExpression, Type: System.UInt32) (Syntax: 'Not i')
IUnaryOperatorExpression (UnaryOperatorKind.Not, Checked) (OperationKind.UnaryOperatorExpression, Type: System.UInt32) (Syntax: 'Not i')
Operand: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.UInt32) (Syntax: 'i')
]]>.Value
......@@ -569,7 +569,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot, Checked) (OperationKind.UnaryOperatorExpression, Type: System.Int64) (Syntax: 'Not i')
IUnaryOperatorExpression (UnaryOperatorKind.Not, Checked) (OperationKind.UnaryOperatorExpression, Type: System.Int64) (Syntax: 'Not i')
Operand: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int64) (Syntax: 'i')
]]>.Value
......@@ -590,7 +590,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot, Checked) (OperationKind.UnaryOperatorExpression, Type: System.UInt64) (Syntax: 'Not i')
IUnaryOperatorExpression (UnaryOperatorKind.Not, Checked) (OperationKind.UnaryOperatorExpression, Type: System.UInt64) (Syntax: 'Not i')
Operand: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.UInt64) (Syntax: 'i')
]]>.Value
......@@ -611,7 +611,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot, Checked) (OperationKind.UnaryOperatorExpression, Type: System.Boolean) (Syntax: 'Not i')
IUnaryOperatorExpression (UnaryOperatorKind.Not, Checked) (OperationKind.UnaryOperatorExpression, Type: System.Boolean) (Syntax: 'Not i')
Operand: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Boolean) (Syntax: 'i')
]]>.Value
......@@ -632,7 +632,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot, Checked) (OperationKind.UnaryOperatorExpression, Type: System.Object) (Syntax: 'Not i')
IUnaryOperatorExpression (UnaryOperatorKind.Not, Checked) (OperationKind.UnaryOperatorExpression, Type: System.Object) (Syntax: 'Not i')
Operand: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Object) (Syntax: 'i')
]]>.Value
......@@ -1113,7 +1113,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot, Checked) (OperationKind.UnaryOperatorExpression, Type: System.SByte) (Syntax: 'Not Method()')
IUnaryOperatorExpression (UnaryOperatorKind.Not, Checked) (OperationKind.UnaryOperatorExpression, Type: System.SByte) (Syntax: 'Not Method()')
Operand: IInvocationExpression ( Function A.Method() As System.SByte) (OperationKind.InvocationExpression, Type: System.SByte) (Syntax: 'Method()')
Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Implicit) (OperationKind.InstanceReferenceExpression, Type: A) (Syntax: 'Method')
Arguments(0)
......@@ -1136,7 +1136,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot, Checked) (OperationKind.UnaryOperatorExpression, Type: System.Byte) (Syntax: 'Not Method()')
IUnaryOperatorExpression (UnaryOperatorKind.Not, Checked) (OperationKind.UnaryOperatorExpression, Type: System.Byte) (Syntax: 'Not Method()')
Operand: IInvocationExpression ( Function A.Method() As System.Byte) (OperationKind.InvocationExpression, Type: System.Byte) (Syntax: 'Method()')
Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Implicit) (OperationKind.InstanceReferenceExpression, Type: A) (Syntax: 'Method')
Arguments(0)
......@@ -1159,7 +1159,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot, Checked) (OperationKind.UnaryOperatorExpression, Type: System.Int16) (Syntax: 'Not Method()')
IUnaryOperatorExpression (UnaryOperatorKind.Not, Checked) (OperationKind.UnaryOperatorExpression, Type: System.Int16) (Syntax: 'Not Method()')
Operand: IInvocationExpression ( Function A.Method() As System.Int16) (OperationKind.InvocationExpression, Type: System.Int16) (Syntax: 'Method()')
Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Implicit) (OperationKind.InstanceReferenceExpression, Type: A) (Syntax: 'Method')
Arguments(0)
......@@ -1182,7 +1182,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot, Checked) (OperationKind.UnaryOperatorExpression, Type: System.UInt16) (Syntax: 'Not Method()')
IUnaryOperatorExpression (UnaryOperatorKind.Not, Checked) (OperationKind.UnaryOperatorExpression, Type: System.UInt16) (Syntax: 'Not Method()')
Operand: IInvocationExpression ( Function A.Method() As System.UInt16) (OperationKind.InvocationExpression, Type: System.UInt16) (Syntax: 'Method()')
Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Implicit) (OperationKind.InstanceReferenceExpression, Type: A) (Syntax: 'Method')
Arguments(0)
......@@ -1205,7 +1205,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot, Checked) (OperationKind.UnaryOperatorExpression, Type: System.Int32) (Syntax: 'Not Method()')
IUnaryOperatorExpression (UnaryOperatorKind.Not, Checked) (OperationKind.UnaryOperatorExpression, Type: System.Int32) (Syntax: 'Not Method()')
Operand: IInvocationExpression ( Function A.Method() As System.Int32) (OperationKind.InvocationExpression, Type: System.Int32) (Syntax: 'Method()')
Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Implicit) (OperationKind.InstanceReferenceExpression, Type: A) (Syntax: 'Method')
Arguments(0)
......@@ -1228,7 +1228,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot, Checked) (OperationKind.UnaryOperatorExpression, Type: System.UInt32) (Syntax: 'Not Method()')
IUnaryOperatorExpression (UnaryOperatorKind.Not, Checked) (OperationKind.UnaryOperatorExpression, Type: System.UInt32) (Syntax: 'Not Method()')
Operand: IInvocationExpression ( Function A.Method() As System.UInt32) (OperationKind.InvocationExpression, Type: System.UInt32) (Syntax: 'Method()')
Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Implicit) (OperationKind.InstanceReferenceExpression, Type: A) (Syntax: 'Method')
Arguments(0)
......@@ -1251,7 +1251,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot, Checked) (OperationKind.UnaryOperatorExpression, Type: System.Int64) (Syntax: 'Not Method()')
IUnaryOperatorExpression (UnaryOperatorKind.Not, Checked) (OperationKind.UnaryOperatorExpression, Type: System.Int64) (Syntax: 'Not Method()')
Operand: IInvocationExpression ( Function A.Method() As System.Int64) (OperationKind.InvocationExpression, Type: System.Int64) (Syntax: 'Method()')
Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Implicit) (OperationKind.InstanceReferenceExpression, Type: A) (Syntax: 'Method')
Arguments(0)
......@@ -1274,7 +1274,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot, Checked) (OperationKind.UnaryOperatorExpression, Type: System.UInt64) (Syntax: 'Not Method()')
IUnaryOperatorExpression (UnaryOperatorKind.Not, Checked) (OperationKind.UnaryOperatorExpression, Type: System.UInt64) (Syntax: 'Not Method()')
Operand: IInvocationExpression ( Function A.Method() As System.UInt64) (OperationKind.InvocationExpression, Type: System.UInt64) (Syntax: 'Method()')
Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Implicit) (OperationKind.InstanceReferenceExpression, Type: A) (Syntax: 'Method')
Arguments(0)
......@@ -1297,7 +1297,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot, Checked) (OperationKind.UnaryOperatorExpression, Type: System.Boolean) (Syntax: 'Not Method()')
IUnaryOperatorExpression (UnaryOperatorKind.Not, Checked) (OperationKind.UnaryOperatorExpression, Type: System.Boolean) (Syntax: 'Not Method()')
Operand: IInvocationExpression ( Function A.Method() As System.Boolean) (OperationKind.InvocationExpression, Type: System.Boolean) (Syntax: 'Method()')
Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Implicit) (OperationKind.InstanceReferenceExpression, Type: A) (Syntax: 'Method')
Arguments(0)
......@@ -1320,7 +1320,7 @@ End Class
]]>.Value
Dim expectedOperationTree = <![CDATA[
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot, Checked) (OperationKind.UnaryOperatorExpression, Type: System.Object) (Syntax: 'Not Method()')
IUnaryOperatorExpression (UnaryOperatorKind.Not, Checked) (OperationKind.UnaryOperatorExpression, Type: System.Object) (Syntax: 'Not Method()')
Operand: IInvocationExpression ( Function A.Method() As System.Object) (OperationKind.InvocationExpression, Type: System.Object) (Syntax: 'Method()')
Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Implicit) (OperationKind.InstanceReferenceExpression, Type: A) (Syntax: 'Method')
Arguments(0)
......@@ -1402,7 +1402,7 @@ End Enum
]]>.Value
Dim expectedOperationTree = <![CDATA[
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot, Checked) (OperationKind.UnaryOperatorExpression, Type: E) (Syntax: 'Not i')
IUnaryOperatorExpression (UnaryOperatorKind.Not, Checked) (OperationKind.UnaryOperatorExpression, Type: E) (Syntax: 'Not i')
Operand: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: E) (Syntax: 'i')
]]>.Value
......@@ -1486,7 +1486,7 @@ End Enum
]]>.Value
Dim expectedOperationTree = <![CDATA[
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot, Checked) (OperationKind.UnaryOperatorExpression, Type: E) (Syntax: 'Not Method()')
IUnaryOperatorExpression (UnaryOperatorKind.Not, Checked) (OperationKind.UnaryOperatorExpression, Type: E) (Syntax: 'Not Method()')
Operand: IInvocationExpression ( Function A.Method() As E) (OperationKind.InvocationExpression, Type: E) (Syntax: 'Method()')
Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Implicit) (OperationKind.InstanceReferenceExpression, Type: A) (Syntax: 'Method')
Arguments(0)
......@@ -1593,7 +1593,7 @@ End CLass
]]>.Value
Dim expectedOperationTree = <![CDATA[
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot) (OperatorMethod: Function CustomType.op_OnesComplement(x As CustomType) As CustomType) (OperationKind.UnaryOperatorExpression, Type: CustomType) (Syntax: 'Not i')
IUnaryOperatorExpression (UnaryOperatorKind.Not) (OperatorMethod: Function CustomType.op_OnesComplement(x As CustomType) As CustomType) (OperationKind.UnaryOperatorExpression, Type: CustomType) (Syntax: 'Not i')
Operand: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: CustomType) (Syntax: 'i')
]]>.Value
......@@ -1702,7 +1702,7 @@ End CLass
]]>.Value
Dim expectedOperationTree = <![CDATA[
IUnaryOperatorExpression (UnaryOperatorKind.LogicalNot) (OperatorMethod: Function CustomType.op_OnesComplement(x As CustomType) As CustomType) (OperationKind.UnaryOperatorExpression, Type: CustomType) (Syntax: 'Not Method()')
IUnaryOperatorExpression (UnaryOperatorKind.Not) (OperatorMethod: Function CustomType.op_OnesComplement(x As CustomType) As CustomType) (OperationKind.UnaryOperatorExpression, Type: CustomType) (Syntax: 'Not Method()')
Operand: IInvocationExpression ( Function A.Method() As CustomType) (OperationKind.InvocationExpression, Type: CustomType) (Syntax: 'Method()')
Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Implicit) (OperationKind.InstanceReferenceExpression, Type: A) (Syntax: 'Method')
Arguments(0)
......
......@@ -1113,12 +1113,15 @@ public override void VisitCompoundAssignmentExpression(ICompoundAssignmentExpres
var kindStr = $"{nameof(BinaryOperatorKind)}.{operation.OperatorKind}";
if (operation.IsLifted)
{
LogString($" ({kindStr}, IsLifted)");
kindStr += ", IsLifted";
}
else
if (operation.IsChecked)
{
LogString($" ({kindStr})");
kindStr += ", Checked";
}
LogString($" ({kindStr})");
LogHasOperatorMethodExpressionCommon(operation);
LogCommonPropertiesAndNewLine(operation);
......@@ -1136,6 +1139,12 @@ public override void VisitIncrementExpression(IIncrementExpression operation)
{
kindStr += ", IsLifted";
}
if (operation.IsChecked)
{
kindStr += ", Checked";
}
LogString($" ({kindStr})");
LogHasOperatorMethodExpressionCommon(operation);
LogCommonPropertiesAndNewLine(operation);
......
......@@ -1555,7 +1555,7 @@ public sealed override void Initialize(AnalysisContext context)
operationContext.ReportDiagnostic(Diagnostic.Create(OperatorMinusMethodDescriptor, unary.Syntax.GetLocation()));
}
if (unary.OperatorKind == UnaryOperatorKind.LogicalNot)
if (unary.OperatorKind == UnaryOperatorKind.Not)
{
operationContext.ReportDiagnostic(Diagnostic.Create(BooleanNotDescriptor, unary.Syntax.GetLocation()));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册