From 8753f9c207ac3727ce64d25361158396c41fb21d Mon Sep 17 00:00:00 2001 From: Heejae Chang Date: Fri, 23 Jun 2017 11:54:07 -0700 Subject: [PATCH 01/16] added IBaseAssignmentExpression and made IComponentAssigntExpression to sit on top of IBaseAssignmentExpression rather than IAssignmentExpression --- .../Generated/Operations.xml.Generated.cs | 2 +- .../Portable/Operations/IAssignmentExpression.cs | 15 +++++++++++++-- .../Operations/ICompoundAssignmentExpression.cs | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs index f847aac3b55db..fbd3604206a3d 100644 --- a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs +++ b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs @@ -366,7 +366,7 @@ public LazyArrayInitializer(Lazy> elementValues, bool /// /// Represents an assignment expression. /// - internal abstract partial class BaseAssignmentExpression : Operation, IAssignmentExpression + internal abstract partial class BaseAssignmentExpression : Operation, IBaseAssignmentExpression { protected BaseAssignmentExpression(OperationKind kind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(kind, isInvalid, syntax, type, constantValue) diff --git a/src/Compilers/Core/Portable/Operations/IAssignmentExpression.cs b/src/Compilers/Core/Portable/Operations/IAssignmentExpression.cs index e7cdbadef0a13..b8ac22d36f111 100644 --- a/src/Compilers/Core/Portable/Operations/IAssignmentExpression.cs +++ b/src/Compilers/Core/Portable/Operations/IAssignmentExpression.cs @@ -5,13 +5,13 @@ namespace Microsoft.CodeAnalysis.Semantics { /// - /// Represents an assignment expression. + /// Represents a base interface for assignment expressions. /// /// /// This interface is reserved for implementation by its associated APIs. We reserve the right to /// change it in the future. /// - public interface IAssignmentExpression : IOperation + public interface IBaseAssignmentExpression : IOperation { /// /// Target of the assignment. @@ -22,5 +22,16 @@ public interface IAssignmentExpression : IOperation /// IOperation Value { get; } } + + /// + /// Represents an assignment expression. + /// + /// + /// This interface is reserved for implementation by its associated APIs. We reserve the right to + /// change it in the future. + /// + public interface IAssignmentExpression : IBaseAssignmentExpression + { + } } diff --git a/src/Compilers/Core/Portable/Operations/ICompoundAssignmentExpression.cs b/src/Compilers/Core/Portable/Operations/ICompoundAssignmentExpression.cs index 3a690d0e39c3c..74183fb5fc644 100644 --- a/src/Compilers/Core/Portable/Operations/ICompoundAssignmentExpression.cs +++ b/src/Compilers/Core/Portable/Operations/ICompoundAssignmentExpression.cs @@ -11,7 +11,7 @@ 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 ICompoundAssignmentExpression : IAssignmentExpression, IHasOperatorMethodExpression + public interface ICompoundAssignmentExpression : IBaseAssignmentExpression, IHasOperatorMethodExpression { /// /// Kind of binary operation. From 6054e7b7d528f8238ff129b9bf1779d11681290b Mon Sep 17 00:00:00 2001 From: Heejae Chang Date: Fri, 23 Jun 2017 12:17:40 -0700 Subject: [PATCH 02/16] added IBaseCompoundAssignmentExpression --- .../Generated/Operations.xml.Generated.cs | 2 +- .../Operations/ICompoundAssignmentExpression.cs | 15 +++++++++++++-- .../Portable/Operations/IIncrementExpression.cs | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs index fbd3604206a3d..6f29b1f98254f 100644 --- a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs +++ b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs @@ -778,7 +778,7 @@ public LazyCatchClause(Lazy handler, ITypeSymbol caughtType, La /// /// Represents an assignment expression that includes a binary operation. /// - internal abstract partial class BaseCompoundAssignmentExpression : BaseAssignmentExpression, IHasOperatorMethodExpression, ICompoundAssignmentExpression + internal abstract partial class BaseCompoundAssignmentExpression : BaseAssignmentExpression, IHasOperatorMethodExpression, IBaseCompoundAssignmentExpression { protected BaseCompoundAssignmentExpression(BinaryOperationKind binaryOperationKind, bool usesOperatorMethod, IMethodSymbol operatorMethod, OperationKind kind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(kind, isInvalid, syntax, type, constantValue) diff --git a/src/Compilers/Core/Portable/Operations/ICompoundAssignmentExpression.cs b/src/Compilers/Core/Portable/Operations/ICompoundAssignmentExpression.cs index 74183fb5fc644..df9ea1c11c4dc 100644 --- a/src/Compilers/Core/Portable/Operations/ICompoundAssignmentExpression.cs +++ b/src/Compilers/Core/Portable/Operations/ICompoundAssignmentExpression.cs @@ -5,18 +5,29 @@ namespace Microsoft.CodeAnalysis.Semantics { /// - /// Represents an assignment expression that includes a binary operation. + /// Represents a base interface for assignment expression that includes a binary operation. /// /// /// This interface is reserved for implementation by its associated APIs. We reserve the right to /// change it in the future. /// - public interface ICompoundAssignmentExpression : IBaseAssignmentExpression, IHasOperatorMethodExpression + public interface IBaseCompoundAssignmentExpression : IBaseAssignmentExpression, IHasOperatorMethodExpression { /// /// Kind of binary operation. /// BinaryOperationKind BinaryOperationKind { get; } } + + /// + /// Represents an assignment expression that includes a binary operation. + /// + /// + /// This interface is reserved for implementation by its associated APIs. We reserve the right to + /// change it in the future. + /// + public interface ICompoundAssignmentExpression : IBaseCompoundAssignmentExpression + { + } } diff --git a/src/Compilers/Core/Portable/Operations/IIncrementExpression.cs b/src/Compilers/Core/Portable/Operations/IIncrementExpression.cs index b4983543eba3d..a3373c9e1af09 100644 --- a/src/Compilers/Core/Portable/Operations/IIncrementExpression.cs +++ b/src/Compilers/Core/Portable/Operations/IIncrementExpression.cs @@ -11,7 +11,7 @@ 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 IIncrementExpression : ICompoundAssignmentExpression + public interface IIncrementExpression : IBaseCompoundAssignmentExpression { /// /// Kind of increment. From acb3bdf67c4d8b1d17a4c366c72d57883de3c408 Mon Sep 17 00:00:00 2001 From: Heejae Chang Date: Fri, 23 Jun 2017 12:32:44 -0700 Subject: [PATCH 03/16] added IBasePropertyReferenceExpression --- .../Generated/Operations.xml.Generated.cs | 2 +- .../Operations/IPropertyReferenceExpression.cs | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs index 6f29b1f98254f..963201ddfd1dc 100644 --- a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs +++ b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs @@ -3336,7 +3336,7 @@ public override TResult Accept(OperationVisitor /// Represents a reference to a property. /// - internal abstract partial class BasePropertyReferenceExpression : MemberReferenceExpression, IPropertyReferenceExpression + internal abstract partial class BasePropertyReferenceExpression : MemberReferenceExpression, IBasePropertyReferenceExpression { protected BasePropertyReferenceExpression(IPropertySymbol property, ISymbol member, OperationKind kind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(member, kind, isInvalid, syntax, type, constantValue) diff --git a/src/Compilers/Core/Portable/Operations/IPropertyReferenceExpression.cs b/src/Compilers/Core/Portable/Operations/IPropertyReferenceExpression.cs index 5a6c8d0f380ee..341923c710609 100644 --- a/src/Compilers/Core/Portable/Operations/IPropertyReferenceExpression.cs +++ b/src/Compilers/Core/Portable/Operations/IPropertyReferenceExpression.cs @@ -5,18 +5,29 @@ namespace Microsoft.CodeAnalysis.Semantics { /// - /// Represents a reference to a property. + /// Represents a base interface for reference to a property. /// /// /// This interface is reserved for implementation by its associated APIs. We reserve the right to /// change it in the future. /// - public interface IPropertyReferenceExpression : IMemberReferenceExpression + public interface IBasePropertyReferenceExpression : IMemberReferenceExpression { /// /// Referenced property. /// IPropertySymbol Property { get; } } + + /// + /// Represents a reference to a property. + /// + /// + /// This interface is reserved for implementation by its associated APIs. We reserve the right to + /// change it in the future. + /// + public interface IPropertyReferenceExpression : IBasePropertyReferenceExpression + { + } } From 56cc92fbb75a4e71efa1df926dc25c6b01e384d0 Mon Sep 17 00:00:00 2001 From: Heejae Chang Date: Fri, 23 Jun 2017 12:45:51 -0700 Subject: [PATCH 04/16] fix some missing issues --- .../Operations/IIndexedPropertyReferenceExpression.cs | 2 +- .../Portable/Operations/VisualBasicOperationFactory.vb | 4 ++-- .../Portable/Diagnostics/CouldHaveMoreSpecificTypeAnalyzer.cs | 2 +- .../Portable/Diagnostics/FieldCouldBeReadOnlyAnalyzer.cs | 2 +- .../Portable/Diagnostics/LocalCouldBeConstAnalyzer.cs | 2 +- .../Utilities/Portable/Diagnostics/OperationTestAnalyzer.cs | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Compilers/Core/Portable/Operations/IIndexedPropertyReferenceExpression.cs b/src/Compilers/Core/Portable/Operations/IIndexedPropertyReferenceExpression.cs index 4c2ff5dff86ba..576b3fcb93138 100644 --- a/src/Compilers/Core/Portable/Operations/IIndexedPropertyReferenceExpression.cs +++ b/src/Compilers/Core/Portable/Operations/IIndexedPropertyReferenceExpression.cs @@ -11,7 +11,7 @@ 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 IIndexedPropertyReferenceExpression : IPropertyReferenceExpression, IHasArgumentsExpression + public interface IIndexedPropertyReferenceExpression : IBasePropertyReferenceExpression, IHasArgumentsExpression { } } diff --git a/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb b/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb index ab12980f8fea3..3b3c9c3688a9e 100644 --- a/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb +++ b/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb @@ -520,7 +520,7 @@ Namespace Microsoft.CodeAnalysis.Semantics Return New LazyArrayInitializer(elementValues, isInvalid, syntax, type, constantValue) End Function - Private Function CreateBoundPropertyAccessOperation(boundPropertyAccess As BoundPropertyAccess) As IPropertyReferenceExpression + Private Function CreateBoundPropertyAccessOperation(boundPropertyAccess As BoundPropertyAccess) As IBasePropertyReferenceExpression Dim instance As Lazy(Of IOperation) = New Lazy(Of IOperation)( Function() If boundPropertyAccess.PropertySymbol.IsShared Then @@ -538,7 +538,7 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim type As ITypeSymbol = boundPropertyAccess.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundPropertyAccess.ConstantValueOpt) Return If(boundPropertyAccess.Arguments.Length > 0, - DirectCast(New LazyIndexedPropertyReferenceExpression([property], instance, member, argumentsInEvaluationOrder, isInvalid, syntax, type, constantValue), IPropertyReferenceExpression), + DirectCast(New LazyIndexedPropertyReferenceExpression([property], instance, member, argumentsInEvaluationOrder, isInvalid, syntax, type, constantValue), IBasePropertyReferenceExpression), New LazyPropertyReferenceExpression([property], instance, member, isInvalid, syntax, type, constantValue)) End Function diff --git a/src/Test/Utilities/Portable/Diagnostics/CouldHaveMoreSpecificTypeAnalyzer.cs b/src/Test/Utilities/Portable/Diagnostics/CouldHaveMoreSpecificTypeAnalyzer.cs index 34613bf7a73e3..6f29c8cae9749 100644 --- a/src/Test/Utilities/Portable/Diagnostics/CouldHaveMoreSpecificTypeAnalyzer.cs +++ b/src/Test/Utilities/Portable/Diagnostics/CouldHaveMoreSpecificTypeAnalyzer.cs @@ -55,7 +55,7 @@ public sealed override void Initialize(AnalysisContext context) operationBlockContext.RegisterOperationAction( (operationContext) => { - IAssignmentExpression assignment = (IAssignmentExpression)operationContext.Operation; + IBaseAssignmentExpression assignment = (IBaseAssignmentExpression)operationContext.Operation; AssignTo(assignment.Target, localsSourceTypes, fieldsSourceTypes, assignment.Value); }, OperationKind.AssignmentExpression, diff --git a/src/Test/Utilities/Portable/Diagnostics/FieldCouldBeReadOnlyAnalyzer.cs b/src/Test/Utilities/Portable/Diagnostics/FieldCouldBeReadOnlyAnalyzer.cs index 0382a345af6b9..2cd96906ea036 100644 --- a/src/Test/Utilities/Portable/Diagnostics/FieldCouldBeReadOnlyAnalyzer.cs +++ b/src/Test/Utilities/Portable/Diagnostics/FieldCouldBeReadOnlyAnalyzer.cs @@ -48,7 +48,7 @@ public sealed override void Initialize(AnalysisContext context) operationBlockContext.RegisterOperationAction( (operationContext) => { - IAssignmentExpression assignment = (IAssignmentExpression)operationContext.Operation; + IBaseAssignmentExpression assignment = (IBaseAssignmentExpression)operationContext.Operation; AssignTo(assignment.Target, inConstructor, staticConstructorType, assignedToFields, mightBecomeReadOnlyFields); }, OperationKind.AssignmentExpression, diff --git a/src/Test/Utilities/Portable/Diagnostics/LocalCouldBeConstAnalyzer.cs b/src/Test/Utilities/Portable/Diagnostics/LocalCouldBeConstAnalyzer.cs index a6cb7a3e6d476..38fb1ddee8879 100644 --- a/src/Test/Utilities/Portable/Diagnostics/LocalCouldBeConstAnalyzer.cs +++ b/src/Test/Utilities/Portable/Diagnostics/LocalCouldBeConstAnalyzer.cs @@ -42,7 +42,7 @@ public sealed override void Initialize(AnalysisContext context) operationBlockContext.RegisterOperationAction( (operationContext) => { - IAssignmentExpression assignment = (IAssignmentExpression)operationContext.Operation; + IBaseAssignmentExpression assignment = (IBaseAssignmentExpression)operationContext.Operation; AssignTo(assignment.Target, assignedToLocals, mightBecomeConstLocals); }, OperationKind.AssignmentExpression, diff --git a/src/Test/Utilities/Portable/Diagnostics/OperationTestAnalyzer.cs b/src/Test/Utilities/Portable/Diagnostics/OperationTestAnalyzer.cs index 5abae752cf3e2..e7e1526863641 100644 --- a/src/Test/Utilities/Portable/Diagnostics/OperationTestAnalyzer.cs +++ b/src/Test/Utilities/Portable/Diagnostics/OperationTestAnalyzer.cs @@ -208,7 +208,7 @@ public sealed override void Initialize(AnalysisContext context) } else if (advanceExpression.Kind == OperationKind.CompoundAssignmentExpression || advanceExpression.Kind == OperationKind.IncrementExpression) { - ICompoundAssignmentExpression advanceAssignment = (ICompoundAssignmentExpression)advanceExpression; + IBaseCompoundAssignmentExpression advanceAssignment = (IBaseCompoundAssignmentExpression)advanceExpression; if (advanceAssignment.Target.Kind == OperationKind.LocalReferenceExpression && ((ILocalReferenceExpression)advanceAssignment.Target).Local == testVariable && From 38dfa2eaf057a4f70bbef4805ac9e082f98fa7c3 Mon Sep 17 00:00:00 2001 From: Heejae Chang Date: Fri, 23 Jun 2017 12:48:06 -0700 Subject: [PATCH 05/16] new public interfaces --- src/Compilers/Core/Portable/PublicAPI.Unshipped.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt index d6f15f3e95c3d..9b8b8791a9ce5 100644 --- a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt +++ b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt @@ -351,6 +351,13 @@ Microsoft.CodeAnalysis.Semantics.IAssignmentExpression.Target.get -> Microsoft.C Microsoft.CodeAnalysis.Semantics.IAssignmentExpression.Value.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IAwaitExpression Microsoft.CodeAnalysis.Semantics.IAwaitExpression.AwaitedValue.get -> Microsoft.CodeAnalysis.IOperation +Microsoft.CodeAnalysis.Semantics.IBaseAssignmentExpression +Microsoft.CodeAnalysis.Semantics.IBaseAssignmentExpression.Target.get -> Microsoft.CodeAnalysis.IOperation +Microsoft.CodeAnalysis.Semantics.IBaseAssignmentExpression.Value.get -> Microsoft.CodeAnalysis.IOperation +Microsoft.CodeAnalysis.Semantics.IBaseCompoundAssignmentExpression +Microsoft.CodeAnalysis.Semantics.IBaseCompoundAssignmentExpression.BinaryOperationKind.get -> Microsoft.CodeAnalysis.Semantics.BinaryOperationKind +Microsoft.CodeAnalysis.Semantics.IBasePropertyReferenceExpression +Microsoft.CodeAnalysis.Semantics.IBasePropertyReferenceExpression.Property.get -> Microsoft.CodeAnalysis.IPropertySymbol Microsoft.CodeAnalysis.Semantics.IBinaryOperatorExpression Microsoft.CodeAnalysis.Semantics.IBinaryOperatorExpression.BinaryOperationKind.get -> Microsoft.CodeAnalysis.Semantics.BinaryOperationKind Microsoft.CodeAnalysis.Semantics.IBinaryOperatorExpression.LeftOperand.get -> Microsoft.CodeAnalysis.IOperation From e9b08af56e684f9752fb731698fcfdb9d160f69d Mon Sep 17 00:00:00 2001 From: Heejae Chang Date: Fri, 23 Jun 2017 12:50:24 -0700 Subject: [PATCH 06/16] removed public apis --- src/Compilers/Core/Portable/PublicAPI.Unshipped.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt index 9b8b8791a9ce5..4002318770060 100644 --- a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt +++ b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt @@ -1,5 +1,9 @@ *REMOVED*Microsoft.CodeAnalysis.Compilation.Emit(System.IO.Stream peStream, System.IO.Stream pdbStream = null, System.IO.Stream xmlDocumentationStream = null, System.IO.Stream win32Resources = null, System.Collections.Generic.IEnumerable manifestResources = null, Microsoft.CodeAnalysis.Emit.EmitOptions options = null, Microsoft.CodeAnalysis.IMethodSymbol debugEntryPoint = null, System.IO.Stream sourceLinkStream = null, System.Collections.Generic.IEnumerable embeddedTexts = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.Emit.EmitResult *REMOVED*Microsoft.CodeAnalysis.Emit.EmitOptions.EmitOptions(bool metadataOnly = false, Microsoft.CodeAnalysis.Emit.DebugInformationFormat debugInformationFormat = (Microsoft.CodeAnalysis.Emit.DebugInformationFormat)0, string pdbFilePath = null, string outputNameOverride = null, int fileAlignment = 0, ulong baseAddress = 0, bool highEntropyVirtualAddressSpace = false, Microsoft.CodeAnalysis.SubsystemVersion subsystemVersion = default(Microsoft.CodeAnalysis.SubsystemVersion), string runtimeMetadataVersion = null, bool tolerateErrors = false, bool includePrivateMembers = false, System.Collections.Immutable.ImmutableArray instrumentationKinds = default(System.Collections.Immutable.ImmutableArray)) -> void +*REMOVED*Microsoft.CodeAnalysis.Semantics.IPropertyReferenceExpression.Property.get -> Microsoft.CodeAnalysis.IPropertySymbol +*REMOVED*Microsoft.CodeAnalysis.Semantics.IAssignmentExpression.Target.get -> Microsoft.CodeAnalysis.IOperation +*REMOVED*Microsoft.CodeAnalysis.Semantics.IAssignmentExpression.Value.get -> Microsoft.CodeAnalysis.IOperation +*REMOVED*Microsoft.CodeAnalysis.Semantics.ICompoundAssignmentExpression.BinaryOperationKind.get -> Microsoft.CodeAnalysis.Semantics.BinaryOperationKind Microsoft.CodeAnalysis.CommandLineArguments.OutputRefFilePath.get -> string Microsoft.CodeAnalysis.CommandLineArguments.RuleSetPath.get -> string Microsoft.CodeAnalysis.CommandLineReference.CommandLineReference(string reference, Microsoft.CodeAnalysis.MetadataReferenceProperties properties) -> void @@ -347,8 +351,6 @@ Microsoft.CodeAnalysis.Semantics.IArrayElementReferenceExpression.Indices.get -> Microsoft.CodeAnalysis.Semantics.IArrayInitializer Microsoft.CodeAnalysis.Semantics.IArrayInitializer.ElementValues.get -> System.Collections.Immutable.ImmutableArray Microsoft.CodeAnalysis.Semantics.IAssignmentExpression -Microsoft.CodeAnalysis.Semantics.IAssignmentExpression.Target.get -> Microsoft.CodeAnalysis.IOperation -Microsoft.CodeAnalysis.Semantics.IAssignmentExpression.Value.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IAwaitExpression Microsoft.CodeAnalysis.Semantics.IAwaitExpression.AwaitedValue.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IBaseAssignmentExpression @@ -376,7 +378,6 @@ Microsoft.CodeAnalysis.Semantics.ICatchClause.ExceptionLocal.get -> Microsoft.Co Microsoft.CodeAnalysis.Semantics.ICatchClause.Filter.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.ICatchClause.Handler.get -> Microsoft.CodeAnalysis.Semantics.IBlockStatement Microsoft.CodeAnalysis.Semantics.ICompoundAssignmentExpression -Microsoft.CodeAnalysis.Semantics.ICompoundAssignmentExpression.BinaryOperationKind.get -> Microsoft.CodeAnalysis.Semantics.BinaryOperationKind Microsoft.CodeAnalysis.Semantics.IConditionalAccessExpression Microsoft.CodeAnalysis.Semantics.IConditionalAccessExpression.ConditionalInstance.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IConditionalAccessExpression.ConditionalValue.get -> Microsoft.CodeAnalysis.IOperation @@ -510,7 +511,6 @@ Microsoft.CodeAnalysis.Semantics.IPointerIndirectionReferenceExpression.Pointer. Microsoft.CodeAnalysis.Semantics.IPropertyInitializer Microsoft.CodeAnalysis.Semantics.IPropertyInitializer.InitializedProperty.get -> Microsoft.CodeAnalysis.IPropertySymbol Microsoft.CodeAnalysis.Semantics.IPropertyReferenceExpression -Microsoft.CodeAnalysis.Semantics.IPropertyReferenceExpression.Property.get -> Microsoft.CodeAnalysis.IPropertySymbol Microsoft.CodeAnalysis.Semantics.IRangeCaseClause Microsoft.CodeAnalysis.Semantics.IRangeCaseClause.MaximumValue.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IRangeCaseClause.MinimumValue.get -> Microsoft.CodeAnalysis.IOperation From a859163445bc6e8d6892a877ee143c6098a7d8ee Mon Sep 17 00:00:00 2001 From: Heejae Chang Date: Fri, 23 Jun 2017 16:24:19 -0700 Subject: [PATCH 07/16] changed IInrementExpression. no longer derived from ICompoundAssignmentExpression --- .../Operations/CSharpOperationFactory.cs | 4 +- .../CSharpOperationFactory_Methods.cs | 10 --- .../Generated/Operations.xml.Generated.cs | 87 ++++++++++++------- .../ICompoundAssignmentExpression.cs | 18 +--- .../Operations/IIncrementExpression.cs | 7 +- .../Portable/Operations/OperationWalker.cs | 1 - .../Core/Portable/PublicAPI.Unshipped.txt | 6 +- .../Compilation/OperationTreeVerifier.cs | 4 +- .../Compilation/TestOperationWalker.cs | 1 - .../Diagnostics/OperationTestAnalyzer.cs | 32 ++++++- 10 files changed, 100 insertions(+), 70 deletions(-) diff --git a/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs b/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs index 085ec1bac3e7e..0b55083e73026 100644 --- a/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs +++ b/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs @@ -564,16 +564,14 @@ private ICompoundAssignmentExpression CreateBoundCompoundAssignmentOperatorOpera private IIncrementExpression CreateBoundIncrementOperatorOperation(BoundIncrementOperator boundIncrementOperator) { UnaryOperationKind incrementOperationKind = Helper.DeriveUnaryOperationKind(boundIncrementOperator.OperatorKind); - BinaryOperationKind binaryOperationKind = Helper.DeriveBinaryOperationKind(incrementOperationKind); Lazy target = new Lazy(() => Create(boundIncrementOperator.Operand)); - Lazy value = new Lazy(() => CreateIncrementOneLiteralExpression(boundIncrementOperator)); bool usesOperatorMethod = (boundIncrementOperator.OperatorKind & UnaryOperatorKind.TypeMask) == UnaryOperatorKind.UserDefined; IMethodSymbol operatorMethod = boundIncrementOperator.MethodOpt; bool isInvalid = boundIncrementOperator.HasErrors; SyntaxNode syntax = boundIncrementOperator.Syntax; ITypeSymbol type = boundIncrementOperator.Type; Optional constantValue = ConvertToOptional(boundIncrementOperator.ConstantValue); - return new LazyIncrementExpression(incrementOperationKind, binaryOperationKind, target, value, usesOperatorMethod, operatorMethod, isInvalid, syntax, type, constantValue); + return new LazyIncrementExpression(incrementOperationKind, target, usesOperatorMethod, operatorMethod, isInvalid, syntax, type, constantValue); } private IInvalidExpression CreateBoundBadExpressionOperation(BoundBadExpression boundBadExpression) diff --git a/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory_Methods.cs b/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory_Methods.cs index 0df7c7a28ca1e..e9b0f56d1eb23 100644 --- a/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory_Methods.cs +++ b/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory_Methods.cs @@ -28,16 +28,6 @@ private ImmutableArray ToStatements(BoundStatement statement) return ImmutableArray.Create(Create(statement)); } - private ILiteralExpression CreateIncrementOneLiteralExpression(BoundIncrementOperator increment) - { - string text = increment.Syntax.ToString(); - bool isInvalid = false; - SyntaxNode syntax = increment.Syntax; - ITypeSymbol type = increment.Type; - Optional constantValue = ConvertToOptional(Semantics.Expression.SynthesizeNumeric(increment.Type, 1)); - return new LiteralExpression(text, isInvalid, syntax, type, constantValue); - } - internal static IArgument CreateArgumentOperation(ArgumentKind kind, IParameterSymbol parameter, IOperation value) { return new Argument(kind, diff --git a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs index 963201ddfd1dc..85bb49dad8b29 100644 --- a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs +++ b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs @@ -778,7 +778,7 @@ public LazyCatchClause(Lazy handler, ITypeSymbol caughtType, La /// /// Represents an assignment expression that includes a binary operation. /// - internal abstract partial class BaseCompoundAssignmentExpression : BaseAssignmentExpression, IHasOperatorMethodExpression, IBaseCompoundAssignmentExpression + internal abstract partial class BaseCompoundAssignmentExpression : BaseAssignmentExpression, IHasOperatorMethodExpression, ICompoundAssignmentExpression { protected BaseCompoundAssignmentExpression(BinaryOperationKind binaryOperationKind, bool usesOperatorMethod, IMethodSymbol operatorMethod, OperationKind kind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(kind, isInvalid, syntax, type, constantValue) @@ -1840,27 +1840,29 @@ public LazyIfStatement(Lazy condition, Lazy ifTrueStatem /// /// Represents an increment expression. /// - internal sealed partial class IncrementExpression : BaseCompoundAssignmentExpression, IIncrementExpression + internal abstract partial class BaseIncrementExpression : Operation, IIncrementExpression { - public IncrementExpression(UnaryOperationKind incrementOperationKind, BinaryOperationKind binaryOperationKind, IOperation target, IOperation value, bool usesOperatorMethod, IMethodSymbol operatorMethod, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(binaryOperationKind, usesOperatorMethod, operatorMethod, OperationKind.IncrementExpression, isInvalid, syntax, type, constantValue) + public BaseIncrementExpression(bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(OperationKind.IncrementExpression, isInvalid, syntax, type, constantValue) { - IncrementOperationKind = incrementOperationKind; - Target = target; - Value = value; } /// /// Kind of increment. /// - public UnaryOperationKind IncrementOperationKind { get; } + public abstract UnaryOperationKind IncrementOperationKind { get; } /// /// Target of the assignment. /// - public override IOperation Target { get; } + public abstract IOperation Target { get; } /// - /// Value to be assigned to the target of the assignment. + /// True if and only if the operation is performed by an operator method. /// - public override IOperation Value { get; } + public abstract bool UsesOperatorMethod { get; } + /// + /// Operation method used by the operation, null if the operation does not use an operator method. + /// + public abstract IMethodSymbol OperatorMethod { get; } + public override void Accept(OperationVisitor visitor) { visitor.VisitIncrementExpression(this); @@ -1874,39 +1876,66 @@ public override TResult Accept(OperationVisitor /// Represents an increment expression. /// - internal sealed partial class LazyIncrementExpression : BaseCompoundAssignmentExpression, IIncrementExpression + internal sealed partial class IncrementExpression : BaseIncrementExpression, IIncrementExpression + { + public IncrementExpression(UnaryOperationKind incrementOperationKind, IOperation target, bool usesOperatorMethod, IMethodSymbol operatorMethod, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(isInvalid, syntax, type, constantValue) + { + IncrementOperationKind = incrementOperationKind; + Target = target; + UsesOperatorMethod = usesOperatorMethod; + OperatorMethod = operatorMethod; + } + + /// + /// Kind of increment. + /// + public override UnaryOperationKind IncrementOperationKind { get; } + /// + /// Target of the assignment. + /// + public override IOperation Target { get; } + /// + /// True if and only if the operation is performed by an operator method. + /// + public override bool UsesOperatorMethod { get; } + /// + /// Operation method used by the operation, null if the operation does not use an operator method. + /// + public override IMethodSymbol OperatorMethod { get; } + } + + /// + /// Represents an increment expression. + /// + internal sealed partial class LazyIncrementExpression : BaseIncrementExpression, IIncrementExpression { private readonly Lazy _lazyTarget; - private readonly Lazy _lazyValue; - public LazyIncrementExpression(UnaryOperationKind incrementOperationKind, BinaryOperationKind binaryOperationKind, Lazy target, Lazy value, bool usesOperatorMethod, IMethodSymbol operatorMethod, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(binaryOperationKind, usesOperatorMethod, operatorMethod, OperationKind.IncrementExpression, isInvalid, syntax, type, constantValue) + public LazyIncrementExpression(UnaryOperationKind incrementOperationKind, Lazy target, bool usesOperatorMethod, IMethodSymbol operatorMethod, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(isInvalid, syntax, type, constantValue) { IncrementOperationKind = incrementOperationKind; _lazyTarget = target ?? throw new System.ArgumentNullException("target"); - _lazyValue = value ?? throw new System.ArgumentNullException("value"); + UsesOperatorMethod = usesOperatorMethod; + OperatorMethod = operatorMethod; } /// /// Kind of increment. /// - public UnaryOperationKind IncrementOperationKind { get; } + public override UnaryOperationKind IncrementOperationKind { get; } /// /// Target of the assignment. /// public override IOperation Target => _lazyTarget.Value; - /// - /// Value to be assigned to the target of the assignment. + /// True if and only if the operation is performed by an operator method. /// - public override IOperation Value => _lazyValue.Value; - - public override void Accept(OperationVisitor visitor) - { - visitor.VisitIncrementExpression(this); - } - public override TResult Accept(OperationVisitor visitor, TArgument argument) - { - return visitor.VisitIncrementExpression(this, argument); - } + public override bool UsesOperatorMethod { get; } + /// + /// Operation method used by the operation, null if the operation does not use an operator method. + /// + public override IMethodSymbol OperatorMethod { get; } } /// @@ -4821,7 +4850,7 @@ internal sealed partial class LazyIsPatternExpression : BaseIsPatternExpression, { private readonly Lazy _lazyExpression; private readonly Lazy _lazyPattern; - + public LazyIsPatternExpression(Lazy lazyExpression, Lazy lazyPattern, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(isInvalid, syntax, type, constantValue) { diff --git a/src/Compilers/Core/Portable/Operations/ICompoundAssignmentExpression.cs b/src/Compilers/Core/Portable/Operations/ICompoundAssignmentExpression.cs index df9ea1c11c4dc..4364a33e95f30 100644 --- a/src/Compilers/Core/Portable/Operations/ICompoundAssignmentExpression.cs +++ b/src/Compilers/Core/Portable/Operations/ICompoundAssignmentExpression.cs @@ -5,29 +5,17 @@ namespace Microsoft.CodeAnalysis.Semantics { /// - /// Represents a base interface for assignment expression that includes a binary operation. + /// Represents an assignment expression that includes a binary operation. /// /// /// This interface is reserved for implementation by its associated APIs. We reserve the right to /// change it in the future. /// - public interface IBaseCompoundAssignmentExpression : IBaseAssignmentExpression, IHasOperatorMethodExpression + public interface ICompoundAssignmentExpression : IBaseAssignmentExpression, IHasOperatorMethodExpression { /// /// Kind of binary operation. /// BinaryOperationKind BinaryOperationKind { get; } } - - /// - /// Represents an assignment expression that includes a binary operation. - /// - /// - /// This interface is reserved for implementation by its associated APIs. We reserve the right to - /// change it in the future. - /// - public interface ICompoundAssignmentExpression : IBaseCompoundAssignmentExpression - { - } -} - +} \ No newline at end of file diff --git a/src/Compilers/Core/Portable/Operations/IIncrementExpression.cs b/src/Compilers/Core/Portable/Operations/IIncrementExpression.cs index a3373c9e1af09..692ceffc3cc64 100644 --- a/src/Compilers/Core/Portable/Operations/IIncrementExpression.cs +++ b/src/Compilers/Core/Portable/Operations/IIncrementExpression.cs @@ -11,8 +11,13 @@ 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 IIncrementExpression : IBaseCompoundAssignmentExpression + public interface IIncrementExpression : IOperation, IHasOperatorMethodExpression { + /// + /// Target of the assignment. + /// + IOperation Target { get; } + /// /// Kind of increment. /// diff --git a/src/Compilers/Core/Portable/Operations/OperationWalker.cs b/src/Compilers/Core/Portable/Operations/OperationWalker.cs index d9038531f9d97..3973bfa4da527 100644 --- a/src/Compilers/Core/Portable/Operations/OperationWalker.cs +++ b/src/Compilers/Core/Portable/Operations/OperationWalker.cs @@ -394,7 +394,6 @@ public override void VisitCompoundAssignmentExpression(ICompoundAssignmentExpres public override void VisitIncrementExpression(IIncrementExpression operation) { Visit(operation.Target); - Visit(operation.Value); } public override void VisitParenthesizedExpression(IParenthesizedExpression operation) diff --git a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt index 4002318770060..a74f3490e911a 100644 --- a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt +++ b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt @@ -1,9 +1,9 @@ *REMOVED*Microsoft.CodeAnalysis.Compilation.Emit(System.IO.Stream peStream, System.IO.Stream pdbStream = null, System.IO.Stream xmlDocumentationStream = null, System.IO.Stream win32Resources = null, System.Collections.Generic.IEnumerable manifestResources = null, Microsoft.CodeAnalysis.Emit.EmitOptions options = null, Microsoft.CodeAnalysis.IMethodSymbol debugEntryPoint = null, System.IO.Stream sourceLinkStream = null, System.Collections.Generic.IEnumerable embeddedTexts = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.Emit.EmitResult *REMOVED*Microsoft.CodeAnalysis.Emit.EmitOptions.EmitOptions(bool metadataOnly = false, Microsoft.CodeAnalysis.Emit.DebugInformationFormat debugInformationFormat = (Microsoft.CodeAnalysis.Emit.DebugInformationFormat)0, string pdbFilePath = null, string outputNameOverride = null, int fileAlignment = 0, ulong baseAddress = 0, bool highEntropyVirtualAddressSpace = false, Microsoft.CodeAnalysis.SubsystemVersion subsystemVersion = default(Microsoft.CodeAnalysis.SubsystemVersion), string runtimeMetadataVersion = null, bool tolerateErrors = false, bool includePrivateMembers = false, System.Collections.Immutable.ImmutableArray instrumentationKinds = default(System.Collections.Immutable.ImmutableArray)) -> void -*REMOVED*Microsoft.CodeAnalysis.Semantics.IPropertyReferenceExpression.Property.get -> Microsoft.CodeAnalysis.IPropertySymbol *REMOVED*Microsoft.CodeAnalysis.Semantics.IAssignmentExpression.Target.get -> Microsoft.CodeAnalysis.IOperation *REMOVED*Microsoft.CodeAnalysis.Semantics.IAssignmentExpression.Value.get -> Microsoft.CodeAnalysis.IOperation *REMOVED*Microsoft.CodeAnalysis.Semantics.ICompoundAssignmentExpression.BinaryOperationKind.get -> Microsoft.CodeAnalysis.Semantics.BinaryOperationKind +*REMOVED*Microsoft.CodeAnalysis.Semantics.IPropertyReferenceExpression.Property.get -> Microsoft.CodeAnalysis.IPropertySymbol Microsoft.CodeAnalysis.CommandLineArguments.OutputRefFilePath.get -> string Microsoft.CodeAnalysis.CommandLineArguments.RuleSetPath.get -> string Microsoft.CodeAnalysis.CommandLineReference.CommandLineReference(string reference, Microsoft.CodeAnalysis.MetadataReferenceProperties properties) -> void @@ -356,8 +356,6 @@ Microsoft.CodeAnalysis.Semantics.IAwaitExpression.AwaitedValue.get -> Microsoft. Microsoft.CodeAnalysis.Semantics.IBaseAssignmentExpression Microsoft.CodeAnalysis.Semantics.IBaseAssignmentExpression.Target.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IBaseAssignmentExpression.Value.get -> Microsoft.CodeAnalysis.IOperation -Microsoft.CodeAnalysis.Semantics.IBaseCompoundAssignmentExpression -Microsoft.CodeAnalysis.Semantics.IBaseCompoundAssignmentExpression.BinaryOperationKind.get -> Microsoft.CodeAnalysis.Semantics.BinaryOperationKind Microsoft.CodeAnalysis.Semantics.IBasePropertyReferenceExpression Microsoft.CodeAnalysis.Semantics.IBasePropertyReferenceExpression.Property.get -> Microsoft.CodeAnalysis.IPropertySymbol Microsoft.CodeAnalysis.Semantics.IBinaryOperatorExpression @@ -378,6 +376,7 @@ Microsoft.CodeAnalysis.Semantics.ICatchClause.ExceptionLocal.get -> Microsoft.Co Microsoft.CodeAnalysis.Semantics.ICatchClause.Filter.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.ICatchClause.Handler.get -> Microsoft.CodeAnalysis.Semantics.IBlockStatement Microsoft.CodeAnalysis.Semantics.ICompoundAssignmentExpression +Microsoft.CodeAnalysis.Semantics.ICompoundAssignmentExpression.BinaryOperationKind.get -> Microsoft.CodeAnalysis.Semantics.BinaryOperationKind Microsoft.CodeAnalysis.Semantics.IConditionalAccessExpression Microsoft.CodeAnalysis.Semantics.IConditionalAccessExpression.ConditionalInstance.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IConditionalAccessExpression.ConditionalValue.get -> Microsoft.CodeAnalysis.IOperation @@ -433,6 +432,7 @@ Microsoft.CodeAnalysis.Semantics.IIfStatement.IfFalseStatement.get -> Microsoft. Microsoft.CodeAnalysis.Semantics.IIfStatement.IfTrueStatement.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IIncrementExpression Microsoft.CodeAnalysis.Semantics.IIncrementExpression.IncrementOperationKind.get -> Microsoft.CodeAnalysis.Semantics.UnaryOperationKind +Microsoft.CodeAnalysis.Semantics.IIncrementExpression.Target.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IIndexedPropertyReferenceExpression Microsoft.CodeAnalysis.Semantics.IInstanceReferenceExpression Microsoft.CodeAnalysis.Semantics.IInstanceReferenceExpression.InstanceReferenceKind.get -> Microsoft.CodeAnalysis.Semantics.InstanceReferenceKind diff --git a/src/Test/Utilities/Portable/Compilation/OperationTreeVerifier.cs b/src/Test/Utilities/Portable/Compilation/OperationTreeVerifier.cs index 8846aeca5e7de..eff762e0b2ee3 100644 --- a/src/Test/Utilities/Portable/Compilation/OperationTreeVerifier.cs +++ b/src/Test/Utilities/Portable/Compilation/OperationTreeVerifier.cs @@ -982,13 +982,11 @@ public override void VisitIncrementExpression(IIncrementExpression operation) LogString(nameof(IIncrementExpression)); var unaryKindStr = $"{nameof(UnaryOperandKind)}.{operation.IncrementOperationKind}"; - var binaryKindStr = $"{nameof(BinaryOperationKind)}.{operation.BinaryOperationKind}"; - LogString($" ({unaryKindStr}) ({binaryKindStr})"); + LogString($" ({unaryKindStr})"); LogHasOperatorMethodExpressionCommon(operation); LogCommonPropertiesAndNewLine(operation); Visit(operation.Target, "Left"); - Visit(operation.Value, "Right"); } public override void VisitParenthesizedExpression(IParenthesizedExpression operation) diff --git a/src/Test/Utilities/Portable/Compilation/TestOperationWalker.cs b/src/Test/Utilities/Portable/Compilation/TestOperationWalker.cs index 5d050384d1a7c..78c3880bef850 100644 --- a/src/Test/Utilities/Portable/Compilation/TestOperationWalker.cs +++ b/src/Test/Utilities/Portable/Compilation/TestOperationWalker.cs @@ -477,7 +477,6 @@ public override void VisitIncrementExpression(IIncrementExpression operation) { var usesOperatorMethod = operation.UsesOperatorMethod; var operatorMethod = operation.OperatorMethod; - var binaryOperationKind = operation.BinaryOperationKind; var incrementOperationKind = operation.IncrementOperationKind; base.VisitIncrementExpression(operation); diff --git a/src/Test/Utilities/Portable/Diagnostics/OperationTestAnalyzer.cs b/src/Test/Utilities/Portable/Diagnostics/OperationTestAnalyzer.cs index e7e1526863641..4bb91a6880fd3 100644 --- a/src/Test/Utilities/Portable/Diagnostics/OperationTestAnalyzer.cs +++ b/src/Test/Utilities/Portable/Diagnostics/OperationTestAnalyzer.cs @@ -206,9 +206,9 @@ public sealed override void Initialize(AnalysisContext context) } } } - else if (advanceExpression.Kind == OperationKind.CompoundAssignmentExpression || advanceExpression.Kind == OperationKind.IncrementExpression) + else if (advanceExpression.Kind == OperationKind.CompoundAssignmentExpression) { - IBaseCompoundAssignmentExpression advanceAssignment = (IBaseCompoundAssignmentExpression)advanceExpression; + ICompoundAssignmentExpression advanceAssignment = (ICompoundAssignmentExpression)advanceExpression; if (advanceAssignment.Target.Kind == OperationKind.LocalReferenceExpression && ((ILocalReferenceExpression)advanceAssignment.Target).Local == testVariable && @@ -220,6 +220,18 @@ public sealed override void Initialize(AnalysisContext context) advanceOperationCode = advanceAssignment.BinaryOperationKind; } } + else if (advanceExpression.Kind == OperationKind.IncrementExpression) + { + IIncrementExpression advanceAssignment = (IIncrementExpression)advanceExpression; + + if (advanceAssignment.Target.Kind == OperationKind.LocalReferenceExpression && + ((ILocalReferenceExpression)advanceAssignment.Target).Local == testVariable) + { + // Advance binary operation is known to involve a reference to the local used in the test and a constant. + advanceIncrement = CreateIncrementOneLiteralExpression(advanceAssignment); + advanceOperationCode = CSharpOperationFactory.Helper.DeriveBinaryOperationKind(advanceAssignment.IncrementOperationKind); + } + } if (advanceIncrement != null) { @@ -257,6 +269,17 @@ public sealed override void Initialize(AnalysisContext context) OperationKind.LoopStatement); } + private static ILiteralExpression CreateIncrementOneLiteralExpression(IIncrementExpression increment) + { + string text = increment.Syntax.ToString(); + bool isInvalid = false; + SyntaxNode syntax = increment.Syntax; + ITypeSymbol type = increment.Type; + Optional constantValue = new Optional(1); + + return new LiteralExpression(text, isInvalid, syntax, type, constantValue); + } + private static int Abs(int value) { return value < 0 ? -value : value; @@ -831,7 +854,7 @@ public sealed override void Initialize(AnalysisContext context) { foreach (var symbol in decl.Variables) { - Report(operationContext, symbol.DeclaringSyntaxReferences.Single().GetSyntax(), LocalVarInitializedDeclarationDescriptor); + Report(operationContext, symbol.DeclaringSyntaxReferences.Single().GetSyntax(), LocalVarInitializedDeclarationDescriptor); } } } @@ -1832,7 +1855,8 @@ public sealed override void Initialize(AnalysisContext context) else if (operation.Kind == OperationKind.IncrementExpression) { var inc = (IIncrementExpression)operation; - if (inc.IsInvalid && inc.BinaryOperationKind == BinaryOperationKind.Invalid) + var binaryOperationKind = CSharpOperationFactory.Helper.DeriveBinaryOperationKind(inc.IncrementOperationKind); + if (inc.IsInvalid && binaryOperationKind == BinaryOperationKind.Invalid) { operationContext.ReportDiagnostic(Diagnostic.Create(InvalidIncrementDescriptor, inc.Syntax.GetLocation())); } From 7dada16003564a8c26df95b1b7e2ed7a9c252865 Mon Sep 17 00:00:00 2001 From: Heejae Chang Date: Mon, 26 Jun 2017 14:58:08 -0700 Subject: [PATCH 08/16] addressed AssignmentExpression design --- .../Operations/CSharpOperationFactory.cs | 4 +- .../Semantic/IOperation/IOperationTests.cs | 6 +- .../Generated/Operations.xml.Generated.cs | 90 +++++++++---------- .../Operations/IAssignmentExpression.cs | 4 +- .../ICompoundAssignmentExpression.cs | 2 +- .../Portable/Operations/OperationFactory.cs | 4 +- .../Core/Portable/Operations/OperationKind.cs | 4 +- .../Portable/Operations/OperationVisitor.cs | 4 +- .../Portable/Operations/OperationWalker.cs | 2 +- .../Core/Portable/PublicAPI.Unshipped.txt | 14 +-- .../Operations/VisualBasicOperationFactory.vb | 2 +- .../VisualBasicOperationFactory_Methods.vb | 8 +- .../Semantic/IOperation/IOperationTests.vb | 12 +-- .../Compilation/OperationTreeVerifier.cs | 4 +- .../Compilation/TestOperationWalker.cs | 4 +- .../CouldHaveMoreSpecificTypeAnalyzer.cs | 4 +- .../FieldCouldBeReadOnlyAnalyzer.cs | 4 +- .../Diagnostics/LocalCouldBeConstAnalyzer.cs | 4 +- .../Diagnostics/OperationTestAnalyzer.cs | 14 +-- 19 files changed, 93 insertions(+), 97 deletions(-) diff --git a/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs b/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs index 0b55083e73026..f6fcc3f5a25ad 100644 --- a/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs +++ b/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs @@ -536,7 +536,7 @@ private IInstanceReferenceExpression CreateBoundThisReferenceOperation(BoundThis return new InstanceReferenceExpression(instanceReferenceKind, isInvalid, syntax, type, constantValue); } - private IAssignmentExpression CreateBoundAssignmentOperatorOperation(BoundAssignmentOperator boundAssignmentOperator) + private ISimpleAssignmentExpression CreateBoundAssignmentOperatorOperation(BoundAssignmentOperator boundAssignmentOperator) { Lazy target = new Lazy(() => Create(boundAssignmentOperator.Left)); Lazy value = new Lazy(() => Create(boundAssignmentOperator.Right)); @@ -544,7 +544,7 @@ private IAssignmentExpression CreateBoundAssignmentOperatorOperation(BoundAssign SyntaxNode syntax = boundAssignmentOperator.Syntax; ITypeSymbol type = boundAssignmentOperator.Type; Optional constantValue = ConvertToOptional(boundAssignmentOperator.ConstantValue); - return new LazyAssignmentExpression(target, value, isInvalid, syntax, type, constantValue); + return new LazySimpleAssignmentExpression(target, value, isInvalid, syntax, type, constantValue); } private ICompoundAssignmentExpression CreateBoundCompoundAssignmentOperatorOperation(BoundCompoundAssignmentOperator boundCompoundAssignmentOperator) diff --git a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests.cs b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests.cs index f6230c8a364a6..1378ade06b789 100644 --- a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests.cs @@ -85,19 +85,19 @@ public void Deconstruct(out int a, out int b, out int c) IOperation operation1 = model.GetOperation(assignments[0]); Assert.NotNull(operation1); Assert.Equal(OperationKind.None, operation1.Kind); - Assert.False(operation1 is IAssignmentExpression); + Assert.False(operation1 is ISimpleAssignmentExpression); Assert.Equal("(x, y, z) = new C()", assignments[1].ToString()); IOperation operation2 = model.GetOperation(assignments[1]); Assert.NotNull(operation2); Assert.Equal(OperationKind.None, operation2.Kind); - Assert.False(operation2 is IAssignmentExpression); + Assert.False(operation2 is ISimpleAssignmentExpression); Assert.Equal("var (a, b) = (1, 2)", assignments[2].ToString()); IOperation operation3 = model.GetOperation(assignments[2]); Assert.NotNull(operation3); Assert.Equal(OperationKind.None, operation3.Kind); - Assert.False(operation3 is IAssignmentExpression); + Assert.False(operation3 is ISimpleAssignmentExpression); } } } \ No newline at end of file diff --git a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs index 85bb49dad8b29..7f6e90281c816 100644 --- a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs +++ b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs @@ -364,11 +364,11 @@ public LazyArrayInitializer(Lazy> elementValues, bool } /// - /// Represents an assignment expression. + /// Represents an base type of assignment expression. /// - internal abstract partial class BaseAssignmentExpression : Operation, IBaseAssignmentExpression + internal abstract partial class AssignmentExpression : Operation, IAssignmentExpression { - protected BaseAssignmentExpression(OperationKind kind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + protected AssignmentExpression(OperationKind kind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(kind, isInvalid, syntax, type, constantValue) { } @@ -385,10 +385,29 @@ protected BaseAssignmentExpression(OperationKind kind, bool isInvalid, SyntaxNod /// /// Represents an assignment expression. /// - internal sealed partial class AssignmentExpression : BaseAssignmentExpression, IAssignmentExpression + internal abstract partial class BaseSimpleAssignmentExpression : AssignmentExpression, ISimpleAssignmentExpression { - public AssignmentExpression(IOperation target, IOperation value, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.AssignmentExpression, isInvalid, syntax, type, constantValue) + public BaseSimpleAssignmentExpression(bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(OperationKind.SimpleAssignmentExpression, isInvalid, syntax, type, constantValue) + { + } + public override void Accept(OperationVisitor visitor) + { + visitor.VisitSimpleAssignmentExpression(this); + } + public override TResult Accept(OperationVisitor visitor, TArgument argument) + { + return visitor.VisitAssignmentExpression(this, argument); + } + } + + /// + /// Represents an assignment expression. + /// + internal sealed partial class SimpleAssignmentExpression : BaseSimpleAssignmentExpression, ISimpleAssignmentExpression + { + public SimpleAssignmentExpression(IOperation target, IOperation value, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(isInvalid, syntax, type, constantValue) { Target = target; Value = value; @@ -401,25 +420,18 @@ public AssignmentExpression(IOperation target, IOperation value, bool isInvalid, /// Value to be assigned to the target of the assignment. /// public override IOperation Value { get; } - public override void Accept(OperationVisitor visitor) - { - visitor.VisitAssignmentExpression(this); - } - public override TResult Accept(OperationVisitor visitor, TArgument argument) - { - return visitor.VisitAssignmentExpression(this, argument); - } } /// /// Represents an assignment expression. /// - internal sealed partial class LazyAssignmentExpression : BaseAssignmentExpression, IAssignmentExpression + internal sealed partial class LazySimpleAssignmentExpression : BaseSimpleAssignmentExpression, ISimpleAssignmentExpression { private readonly Lazy _lazyTarget; private readonly Lazy _lazyValue; - public LazyAssignmentExpression(Lazy target, Lazy value, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(OperationKind.AssignmentExpression, isInvalid, syntax, type, constantValue) + public LazySimpleAssignmentExpression(Lazy target, Lazy value, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(isInvalid, syntax, type, constantValue) { _lazyTarget = target ?? throw new System.ArgumentNullException("target"); _lazyValue = value ?? throw new System.ArgumentNullException("value"); @@ -433,15 +445,6 @@ public LazyAssignmentExpression(Lazy target, Lazy value, /// Value to be assigned to the target of the assignment. /// public override IOperation Value => _lazyValue.Value; - - public override void Accept(OperationVisitor visitor) - { - visitor.VisitAssignmentExpression(this); - } - public override TResult Accept(OperationVisitor visitor, TArgument argument) - { - return visitor.VisitAssignmentExpression(this, argument); - } } /// @@ -778,10 +781,10 @@ public LazyCatchClause(Lazy handler, ITypeSymbol caughtType, La /// /// Represents an assignment expression that includes a binary operation. /// - internal abstract partial class BaseCompoundAssignmentExpression : BaseAssignmentExpression, IHasOperatorMethodExpression, ICompoundAssignmentExpression + internal abstract partial class BaseCompoundAssignmentExpression : AssignmentExpression, IHasOperatorMethodExpression, ICompoundAssignmentExpression { - protected BaseCompoundAssignmentExpression(BinaryOperationKind binaryOperationKind, bool usesOperatorMethod, IMethodSymbol operatorMethod, OperationKind kind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(kind, isInvalid, syntax, type, constantValue) + protected BaseCompoundAssignmentExpression(BinaryOperationKind binaryOperationKind, bool usesOperatorMethod, IMethodSymbol operatorMethod, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(OperationKind.CompoundAssignmentExpression, isInvalid, syntax, type, constantValue) { BinaryOperationKind = binaryOperationKind; UsesOperatorMethod = usesOperatorMethod; @@ -799,6 +802,15 @@ protected BaseCompoundAssignmentExpression(BinaryOperationKind binaryOperationKi /// Operation method used by the operation, null if the operation does not use an operator method. /// public IMethodSymbol OperatorMethod { get; } + + public override void Accept(OperationVisitor visitor) + { + visitor.VisitCompoundAssignmentExpression(this); + } + public override TResult Accept(OperationVisitor visitor, TArgument argument) + { + return visitor.VisitCompoundAssignmentExpression(this, argument); + } } /// @@ -807,7 +819,7 @@ protected BaseCompoundAssignmentExpression(BinaryOperationKind binaryOperationKi internal sealed partial class CompoundAssignmentExpression : BaseCompoundAssignmentExpression, IHasOperatorMethodExpression, ICompoundAssignmentExpression { public CompoundAssignmentExpression(BinaryOperationKind binaryOperationKind, IOperation target, IOperation value, bool usesOperatorMethod, IMethodSymbol operatorMethod, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(binaryOperationKind, usesOperatorMethod, operatorMethod, OperationKind.CompoundAssignmentExpression, isInvalid, syntax, type, constantValue) + base(binaryOperationKind, usesOperatorMethod, operatorMethod, isInvalid, syntax, type, constantValue) { Target = target; Value = value; @@ -820,14 +832,6 @@ public CompoundAssignmentExpression(BinaryOperationKind binaryOperationKind, IOp /// Value to be assigned to the target of the assignment. /// public override IOperation Value { get; } - public override void Accept(OperationVisitor visitor) - { - visitor.VisitCompoundAssignmentExpression(this); - } - public override TResult Accept(OperationVisitor visitor, TArgument argument) - { - return visitor.VisitCompoundAssignmentExpression(this, argument); - } } /// @@ -838,7 +842,8 @@ internal sealed partial class LazyCompoundAssignmentExpression : BaseCompoundAss private readonly Lazy _lazyTarget; private readonly Lazy _lazyValue; - public LazyCompoundAssignmentExpression(BinaryOperationKind binaryOperationKind, Lazy target, Lazy value, bool usesOperatorMethod, IMethodSymbol operatorMethod, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(binaryOperationKind, usesOperatorMethod, operatorMethod, OperationKind.CompoundAssignmentExpression, isInvalid, syntax, type, constantValue) + public LazyCompoundAssignmentExpression(BinaryOperationKind binaryOperationKind, Lazy target, Lazy value, bool usesOperatorMethod, IMethodSymbol operatorMethod, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(binaryOperationKind, usesOperatorMethod, operatorMethod, isInvalid, syntax, type, constantValue) { _lazyTarget = target ?? throw new System.ArgumentNullException("target"); _lazyValue = value ?? throw new System.ArgumentNullException("value"); @@ -852,15 +857,6 @@ public LazyCompoundAssignmentExpression(BinaryOperationKind binaryOperationKind, /// Value to be assigned to the target of the assignment. /// public override IOperation Value => _lazyValue.Value; - - public override void Accept(OperationVisitor visitor) - { - visitor.VisitCompoundAssignmentExpression(this); - } - public override TResult Accept(OperationVisitor visitor, TArgument argument) - { - return visitor.VisitCompoundAssignmentExpression(this, argument); - } } /// diff --git a/src/Compilers/Core/Portable/Operations/IAssignmentExpression.cs b/src/Compilers/Core/Portable/Operations/IAssignmentExpression.cs index b8ac22d36f111..a9ac51794f3bf 100644 --- a/src/Compilers/Core/Portable/Operations/IAssignmentExpression.cs +++ b/src/Compilers/Core/Portable/Operations/IAssignmentExpression.cs @@ -11,7 +11,7 @@ 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 IBaseAssignmentExpression : IOperation + public interface IAssignmentExpression : IOperation { /// /// Target of the assignment. @@ -30,7 +30,7 @@ public interface IBaseAssignmentExpression : IOperation /// This interface is reserved for implementation by its associated APIs. We reserve the right to /// change it in the future. /// - public interface IAssignmentExpression : IBaseAssignmentExpression + public interface ISimpleAssignmentExpression : IAssignmentExpression { } } diff --git a/src/Compilers/Core/Portable/Operations/ICompoundAssignmentExpression.cs b/src/Compilers/Core/Portable/Operations/ICompoundAssignmentExpression.cs index 4364a33e95f30..e4721c0c1e8bd 100644 --- a/src/Compilers/Core/Portable/Operations/ICompoundAssignmentExpression.cs +++ b/src/Compilers/Core/Portable/Operations/ICompoundAssignmentExpression.cs @@ -11,7 +11,7 @@ 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 ICompoundAssignmentExpression : IBaseAssignmentExpression, IHasOperatorMethodExpression + public interface ICompoundAssignmentExpression : IAssignmentExpression, IHasOperatorMethodExpression { /// /// Kind of binary operation. diff --git a/src/Compilers/Core/Portable/Operations/OperationFactory.cs b/src/Compilers/Core/Portable/Operations/OperationFactory.cs index 86a07cea83320..426221905986e 100644 --- a/src/Compilers/Core/Portable/Operations/OperationFactory.cs +++ b/src/Compilers/Core/Portable/Operations/OperationFactory.cs @@ -37,10 +37,10 @@ public static IConditionalChoiceExpression CreateConditionalChoiceExpression(IOp default(Optional)); } - public static IExpressionStatement CreateAssignmentExpressionStatement(IOperation target, IOperation value, SyntaxNode syntax) + public static IExpressionStatement CreateSimpleAssignmentExpressionStatement(IOperation target, IOperation value, SyntaxNode syntax) { var isInvalid = target == null || target.IsInvalid || value == null || value.IsInvalid; - var expression = new AssignmentExpression(target, value, isInvalid, syntax, target.Type, default(Optional)); + var expression = new SimpleAssignmentExpression(target, value, isInvalid, syntax, target.Type, default(Optional)); return new ExpressionStatement(expression, expression.IsInvalid, syntax, type: null, constantValue: default(Optional)); } diff --git a/src/Compilers/Core/Portable/Operations/OperationKind.cs b/src/Compilers/Core/Portable/Operations/OperationKind.cs index dd10957f10e2f..c7c5ab559d231 100644 --- a/src/Compilers/Core/Portable/Operations/OperationKind.cs +++ b/src/Compilers/Core/Portable/Operations/OperationKind.cs @@ -114,8 +114,8 @@ public enum OperationKind IsTypeExpression = 0x116, /// Indicates an . AwaitExpression = 0x117, - /// Indicates an . - AssignmentExpression = 0x118, + /// Indicates an . + SimpleAssignmentExpression = 0x118, /// Indicates an . CompoundAssignmentExpression = 0x119, /// Indicates an . diff --git a/src/Compilers/Core/Portable/Operations/OperationVisitor.cs b/src/Compilers/Core/Portable/Operations/OperationVisitor.cs index ce1ba3a56f66c..e037da2394a04 100644 --- a/src/Compilers/Core/Portable/Operations/OperationVisitor.cs +++ b/src/Compilers/Core/Portable/Operations/OperationVisitor.cs @@ -340,7 +340,7 @@ public virtual void VisitArrayInitializer(IArrayInitializer operation) DefaultVisit(operation); } - public virtual void VisitAssignmentExpression(IAssignmentExpression operation) + public virtual void VisitSimpleAssignmentExpression(ISimpleAssignmentExpression operation) { DefaultVisit(operation); } @@ -770,7 +770,7 @@ public virtual TResult VisitArrayInitializer(IArrayInitializer operation, TArgum return DefaultVisit(operation, argument); } - public virtual TResult VisitAssignmentExpression(IAssignmentExpression operation, TArgument argument) + public virtual TResult VisitAssignmentExpression(ISimpleAssignmentExpression operation, TArgument argument) { return DefaultVisit(operation, argument); } diff --git a/src/Compilers/Core/Portable/Operations/OperationWalker.cs b/src/Compilers/Core/Portable/Operations/OperationWalker.cs index 3973bfa4da527..33ecbf6ccc9db 100644 --- a/src/Compilers/Core/Portable/Operations/OperationWalker.cs +++ b/src/Compilers/Core/Portable/Operations/OperationWalker.cs @@ -379,7 +379,7 @@ public override void VisitArrayInitializer(IArrayInitializer operation) VisitArray(operation.ElementValues); } - public override void VisitAssignmentExpression(IAssignmentExpression operation) + public override void VisitSimpleAssignmentExpression(ISimpleAssignmentExpression operation) { Visit(operation.Target); Visit(operation.Value); diff --git a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt index a74f3490e911a..b3486038b9776 100644 --- a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt +++ b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt @@ -59,7 +59,6 @@ Microsoft.CodeAnalysis.OperationKind.Argument = 1031 -> Microsoft.CodeAnalysis.O Microsoft.CodeAnalysis.OperationKind.ArrayCreationExpression = 276 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.ArrayElementReferenceExpression = 260 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.ArrayInitializer = 1029 -> Microsoft.CodeAnalysis.OperationKind -Microsoft.CodeAnalysis.OperationKind.AssignmentExpression = 280 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.AwaitExpression = 279 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.BinaryOperatorExpression = 270 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.BlockStatement = 2 -> Microsoft.CodeAnalysis.OperationKind @@ -119,6 +118,7 @@ Microsoft.CodeAnalysis.OperationKind.PropertyReferenceExpression = 266 -> Micros Microsoft.CodeAnalysis.OperationKind.RangeCaseClause = 1036 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.RelationalCaseClause = 1035 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.ReturnStatement = 11 -> Microsoft.CodeAnalysis.OperationKind +Microsoft.CodeAnalysis.OperationKind.SimpleAssignmentExpression = 280 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.SingleValueCaseClause = 1034 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.SizeOfExpression = 514 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.StopStatement = 80 -> Microsoft.CodeAnalysis.OperationKind @@ -351,11 +351,10 @@ Microsoft.CodeAnalysis.Semantics.IArrayElementReferenceExpression.Indices.get -> Microsoft.CodeAnalysis.Semantics.IArrayInitializer Microsoft.CodeAnalysis.Semantics.IArrayInitializer.ElementValues.get -> System.Collections.Immutable.ImmutableArray Microsoft.CodeAnalysis.Semantics.IAssignmentExpression +Microsoft.CodeAnalysis.Semantics.IAssignmentExpression.Target.get -> Microsoft.CodeAnalysis.IOperation +Microsoft.CodeAnalysis.Semantics.IAssignmentExpression.Value.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IAwaitExpression Microsoft.CodeAnalysis.Semantics.IAwaitExpression.AwaitedValue.get -> Microsoft.CodeAnalysis.IOperation -Microsoft.CodeAnalysis.Semantics.IBaseAssignmentExpression -Microsoft.CodeAnalysis.Semantics.IBaseAssignmentExpression.Target.get -> Microsoft.CodeAnalysis.IOperation -Microsoft.CodeAnalysis.Semantics.IBaseAssignmentExpression.Value.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IBasePropertyReferenceExpression Microsoft.CodeAnalysis.Semantics.IBasePropertyReferenceExpression.Property.get -> Microsoft.CodeAnalysis.IPropertySymbol Microsoft.CodeAnalysis.Semantics.IBinaryOperatorExpression @@ -519,6 +518,7 @@ Microsoft.CodeAnalysis.Semantics.IRelationalCaseClause.Relation.get -> Microsoft Microsoft.CodeAnalysis.Semantics.IRelationalCaseClause.Value.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IReturnStatement Microsoft.CodeAnalysis.Semantics.IReturnStatement.ReturnedValue.get -> Microsoft.CodeAnalysis.IOperation +Microsoft.CodeAnalysis.Semantics.ISimpleAssignmentExpression Microsoft.CodeAnalysis.Semantics.ISingleValueCaseClause Microsoft.CodeAnalysis.Semantics.ISingleValueCaseClause.Equality.get -> Microsoft.CodeAnalysis.Semantics.BinaryOperationKind Microsoft.CodeAnalysis.Semantics.ISingleValueCaseClause.Value.get -> Microsoft.CodeAnalysis.IOperation @@ -709,7 +709,6 @@ override Microsoft.CodeAnalysis.Semantics.OperationWalker.VisitArgument(Microsof override Microsoft.CodeAnalysis.Semantics.OperationWalker.VisitArrayCreationExpression(Microsoft.CodeAnalysis.Semantics.IArrayCreationExpression operation) -> void override Microsoft.CodeAnalysis.Semantics.OperationWalker.VisitArrayElementReferenceExpression(Microsoft.CodeAnalysis.Semantics.IArrayElementReferenceExpression operation) -> void override Microsoft.CodeAnalysis.Semantics.OperationWalker.VisitArrayInitializer(Microsoft.CodeAnalysis.Semantics.IArrayInitializer operation) -> void -override Microsoft.CodeAnalysis.Semantics.OperationWalker.VisitAssignmentExpression(Microsoft.CodeAnalysis.Semantics.IAssignmentExpression operation) -> void override Microsoft.CodeAnalysis.Semantics.OperationWalker.VisitAwaitExpression(Microsoft.CodeAnalysis.Semantics.IAwaitExpression operation) -> void override Microsoft.CodeAnalysis.Semantics.OperationWalker.VisitBinaryOperatorExpression(Microsoft.CodeAnalysis.Semantics.IBinaryOperatorExpression operation) -> void override Microsoft.CodeAnalysis.Semantics.OperationWalker.VisitBlockStatement(Microsoft.CodeAnalysis.Semantics.IBlockStatement operation) -> void @@ -767,6 +766,7 @@ override Microsoft.CodeAnalysis.Semantics.OperationWalker.VisitPropertyReference override Microsoft.CodeAnalysis.Semantics.OperationWalker.VisitRangeCaseClause(Microsoft.CodeAnalysis.Semantics.IRangeCaseClause operation) -> void override Microsoft.CodeAnalysis.Semantics.OperationWalker.VisitRelationalCaseClause(Microsoft.CodeAnalysis.Semantics.IRelationalCaseClause operation) -> void override Microsoft.CodeAnalysis.Semantics.OperationWalker.VisitReturnStatement(Microsoft.CodeAnalysis.Semantics.IReturnStatement operation) -> void +override Microsoft.CodeAnalysis.Semantics.OperationWalker.VisitSimpleAssignmentExpression(Microsoft.CodeAnalysis.Semantics.ISimpleAssignmentExpression operation) -> void override Microsoft.CodeAnalysis.Semantics.OperationWalker.VisitSingleValueCaseClause(Microsoft.CodeAnalysis.Semantics.ISingleValueCaseClause operation) -> void override Microsoft.CodeAnalysis.Semantics.OperationWalker.VisitSizeOfExpression(Microsoft.CodeAnalysis.Semantics.ISizeOfExpression operation) -> void override Microsoft.CodeAnalysis.Semantics.OperationWalker.VisitStopStatement(Microsoft.CodeAnalysis.Semantics.IStopStatement operation) -> void @@ -814,7 +814,6 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitArgument(Microsof virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitArrayCreationExpression(Microsoft.CodeAnalysis.Semantics.IArrayCreationExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitArrayElementReferenceExpression(Microsoft.CodeAnalysis.Semantics.IArrayElementReferenceExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitArrayInitializer(Microsoft.CodeAnalysis.Semantics.IArrayInitializer operation) -> void -virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitAssignmentExpression(Microsoft.CodeAnalysis.Semantics.IAssignmentExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitAwaitExpression(Microsoft.CodeAnalysis.Semantics.IAwaitExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitBinaryOperatorExpression(Microsoft.CodeAnalysis.Semantics.IBinaryOperatorExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitBlockStatement(Microsoft.CodeAnalysis.Semantics.IBlockStatement operation) -> void @@ -872,6 +871,7 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitPropertyReference virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitRangeCaseClause(Microsoft.CodeAnalysis.Semantics.IRangeCaseClause operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitRelationalCaseClause(Microsoft.CodeAnalysis.Semantics.IRelationalCaseClause operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitReturnStatement(Microsoft.CodeAnalysis.Semantics.IReturnStatement operation) -> void +virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitSimpleAssignmentExpression(Microsoft.CodeAnalysis.Semantics.ISimpleAssignmentExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitSingleValueCaseClause(Microsoft.CodeAnalysis.Semantics.ISingleValueCaseClause operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitSizeOfExpression(Microsoft.CodeAnalysis.Semantics.ISizeOfExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitStopStatement(Microsoft.CodeAnalysis.Semantics.IStopStatement operation) -> void @@ -896,7 +896,7 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.Vi virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitArrayCreationExpression(Microsoft.CodeAnalysis.Semantics.IArrayCreationExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitArrayElementReferenceExpression(Microsoft.CodeAnalysis.Semantics.IArrayElementReferenceExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitArrayInitializer(Microsoft.CodeAnalysis.Semantics.IArrayInitializer operation, TArgument argument) -> TResult -virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitAssignmentExpression(Microsoft.CodeAnalysis.Semantics.IAssignmentExpression operation, TArgument argument) -> TResult +virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitAssignmentExpression(Microsoft.CodeAnalysis.Semantics.ISimpleAssignmentExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitAwaitExpression(Microsoft.CodeAnalysis.Semantics.IAwaitExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitBinaryOperatorExpression(Microsoft.CodeAnalysis.Semantics.IBinaryOperatorExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitBlockStatement(Microsoft.CodeAnalysis.Semantics.IBlockStatement operation, TArgument argument) -> TResult diff --git a/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb b/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb index 3b3c9c3688a9e..dcfc0373386f1 100644 --- a/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb +++ b/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb @@ -207,7 +207,7 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundAssignmentOperator.Syntax Dim type As ITypeSymbol = boundAssignmentOperator.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundAssignmentOperator.ConstantValueOpt) - Return New LazyAssignmentExpression(target, value, isInvalid, syntax, type, constantValue) + Return New LazySimpleAssignmentExpression(target, value, isInvalid, syntax, type, constantValue) End If End Function diff --git a/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory_Methods.vb b/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory_Methods.vb index 77427cb4ab10a..5b7da31ef7b13 100644 --- a/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory_Methods.vb +++ b/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory_Methods.vb @@ -31,7 +31,7 @@ Namespace Microsoft.CodeAnalysis.Semantics End Select End If - Return OperationKind.AssignmentExpression + Return OperationKind.SimpleAssignmentExpression End Function Private Function GetUserDefinedBinaryOperatorChild([operator] As BoundUserDefinedBinaryOperator, index As Integer) As IOperation @@ -242,14 +242,14 @@ Namespace Microsoft.CodeAnalysis.Semantics ' ControlVariable = InitialValue Dim controlReference As IOperation = Create(boundFor.ControlVariable) If controlReference IsNot Nothing Then - statements.Add(OperationFactory.CreateAssignmentExpressionStatement(controlReference, Create(boundFor.InitialValue), boundFor.InitialValue.Syntax)) + statements.Add(OperationFactory.CreateSimpleAssignmentExpressionStatement(controlReference, Create(boundFor.InitialValue), boundFor.InitialValue.Syntax)) End If ' T0 = LimitValue If Not boundFor.LimitValue.IsConstant Then Dim value = Create(boundFor.LimitValue) statements.Add( - OperationFactory.CreateAssignmentExpressionStatement( + OperationFactory.CreateSimpleAssignmentExpressionStatement( New SyntheticLocalReferenceExpression( SyntheticLocalKind.ForLoopLimitValue, Create(boundFor), @@ -263,7 +263,7 @@ Namespace Microsoft.CodeAnalysis.Semantics If boundFor.StepValue IsNot Nothing AndAlso Not boundFor.StepValue.IsConstant Then Dim value = Create(boundFor.StepValue) statements.Add( - OperationFactory.CreateAssignmentExpressionStatement( + OperationFactory.CreateSimpleAssignmentExpressionStatement( New SyntheticLocalReferenceExpression( SyntheticLocalKind.ForLoopStepValue, Create(boundFor), diff --git a/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests.vb b/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests.vb index fbe0968242744..fa682f04356bb 100644 --- a/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests.vb +++ b/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests.vb @@ -56,8 +56,8 @@ End Module Dim statement1 As IOperation = model.GetOperation(nodes(0)) Assert.Equal(statement1.Kind, OperationKind.ExpressionStatement) Dim expression1 As IOperation = DirectCast(statement1, IExpressionStatement).Expression - Assert.Equal(expression1.Kind, OperationKind.AssignmentExpression) - Dim assignment1 As IAssignmentExpression = DirectCast(expression1, IAssignmentExpression) + Assert.Equal(expression1.Kind, OperationKind.SimpleAssignmentExpression) + Dim assignment1 As ISimpleAssignmentExpression = DirectCast(expression1, ISimpleAssignmentExpression) Assert.Equal(assignment1.Value.Kind, OperationKind.BinaryOperatorExpression) Dim add1 As IBinaryOperatorExpression = DirectCast(assignment1.Value, IBinaryOperatorExpression) Assert.Equal(add1.BinaryOperationKind, BinaryOperationKind.OperatorMethodAdd) @@ -86,8 +86,8 @@ IExpressionStatement (OperationKind.ExpressionStatement, IsInvalid) (Syntax: 'x Dim statement2 As IOperation = model.GetOperation(nodes(1)) Assert.Equal(statement2.Kind, OperationKind.ExpressionStatement) Dim expression2 As IOperation = DirectCast(statement2, IExpressionStatement).Expression - Assert.Equal(expression2.Kind, OperationKind.AssignmentExpression) - Dim assignment2 As IAssignmentExpression = DirectCast(expression2, IAssignmentExpression) + Assert.Equal(expression2.Kind, OperationKind.SimpleAssignmentExpression) + Dim assignment2 As ISimpleAssignmentExpression = DirectCast(expression2, ISimpleAssignmentExpression) Assert.Equal(assignment2.Value.Kind, OperationKind.BinaryOperatorExpression) Dim add2 As IBinaryOperatorExpression = DirectCast(assignment2.Value, IBinaryOperatorExpression) Assert.Equal(add2.BinaryOperationKind, BinaryOperationKind.OperatorMethodAdd) @@ -116,8 +116,8 @@ IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'x = x + y') Dim statement3 As IOperation = model.GetOperation(nodes(2)) Assert.Equal(statement3.Kind, OperationKind.ExpressionStatement) Dim expression3 As IOperation = DirectCast(statement3, IExpressionStatement).Expression - Assert.Equal(expression3.Kind, OperationKind.AssignmentExpression) - Dim assignment3 As IAssignmentExpression = DirectCast(expression3, IAssignmentExpression) + Assert.Equal(expression3.Kind, OperationKind.SimpleAssignmentExpression) + Dim assignment3 As ISimpleAssignmentExpression = DirectCast(expression3, ISimpleAssignmentExpression) Assert.Equal(assignment3.Value.Kind, OperationKind.UnaryOperatorExpression) Dim negate3 As IUnaryOperatorExpression = DirectCast(assignment3.Value, IUnaryOperatorExpression) Assert.Equal(negate3.UnaryOperationKind, UnaryOperationKind.OperatorMethodMinus) diff --git a/src/Test/Utilities/Portable/Compilation/OperationTreeVerifier.cs b/src/Test/Utilities/Portable/Compilation/OperationTreeVerifier.cs index eff762e0b2ee3..f07ab3c46f14f 100644 --- a/src/Test/Utilities/Portable/Compilation/OperationTreeVerifier.cs +++ b/src/Test/Utilities/Portable/Compilation/OperationTreeVerifier.cs @@ -955,9 +955,9 @@ public override void VisitArrayInitializer(IArrayInitializer operation) VisitArray(operation.ElementValues, "Element Values", logElementCount: true); } - public override void VisitAssignmentExpression(IAssignmentExpression operation) + public override void VisitSimpleAssignmentExpression(ISimpleAssignmentExpression operation) { - LogString(nameof(IAssignmentExpression)); + LogString(nameof(ISimpleAssignmentExpression)); LogCommonPropertiesAndNewLine(operation); Visit(operation.Target, "Left"); diff --git a/src/Test/Utilities/Portable/Compilation/TestOperationWalker.cs b/src/Test/Utilities/Portable/Compilation/TestOperationWalker.cs index 78c3880bef850..032512364f342 100644 --- a/src/Test/Utilities/Portable/Compilation/TestOperationWalker.cs +++ b/src/Test/Utilities/Portable/Compilation/TestOperationWalker.cs @@ -459,9 +459,9 @@ public override void VisitArrayInitializer(IArrayInitializer operation) base.VisitArrayInitializer(operation); } - public override void VisitAssignmentExpression(IAssignmentExpression operation) + public override void VisitSimpleAssignmentExpression(ISimpleAssignmentExpression operation) { - base.VisitAssignmentExpression(operation); + base.VisitSimpleAssignmentExpression(operation); } public override void VisitCompoundAssignmentExpression(ICompoundAssignmentExpression operation) diff --git a/src/Test/Utilities/Portable/Diagnostics/CouldHaveMoreSpecificTypeAnalyzer.cs b/src/Test/Utilities/Portable/Diagnostics/CouldHaveMoreSpecificTypeAnalyzer.cs index 6f29c8cae9749..a657eb8767816 100644 --- a/src/Test/Utilities/Portable/Diagnostics/CouldHaveMoreSpecificTypeAnalyzer.cs +++ b/src/Test/Utilities/Portable/Diagnostics/CouldHaveMoreSpecificTypeAnalyzer.cs @@ -55,10 +55,10 @@ public sealed override void Initialize(AnalysisContext context) operationBlockContext.RegisterOperationAction( (operationContext) => { - IBaseAssignmentExpression assignment = (IBaseAssignmentExpression)operationContext.Operation; + IAssignmentExpression assignment = (IAssignmentExpression)operationContext.Operation; AssignTo(assignment.Target, localsSourceTypes, fieldsSourceTypes, assignment.Value); }, - OperationKind.AssignmentExpression, + OperationKind.SimpleAssignmentExpression, OperationKind.CompoundAssignmentExpression, OperationKind.IncrementExpression); diff --git a/src/Test/Utilities/Portable/Diagnostics/FieldCouldBeReadOnlyAnalyzer.cs b/src/Test/Utilities/Portable/Diagnostics/FieldCouldBeReadOnlyAnalyzer.cs index 2cd96906ea036..1bcc9973736e3 100644 --- a/src/Test/Utilities/Portable/Diagnostics/FieldCouldBeReadOnlyAnalyzer.cs +++ b/src/Test/Utilities/Portable/Diagnostics/FieldCouldBeReadOnlyAnalyzer.cs @@ -48,10 +48,10 @@ public sealed override void Initialize(AnalysisContext context) operationBlockContext.RegisterOperationAction( (operationContext) => { - IBaseAssignmentExpression assignment = (IBaseAssignmentExpression)operationContext.Operation; + IAssignmentExpression assignment = (IAssignmentExpression)operationContext.Operation; AssignTo(assignment.Target, inConstructor, staticConstructorType, assignedToFields, mightBecomeReadOnlyFields); }, - OperationKind.AssignmentExpression, + OperationKind.SimpleAssignmentExpression, OperationKind.CompoundAssignmentExpression, OperationKind.IncrementExpression); diff --git a/src/Test/Utilities/Portable/Diagnostics/LocalCouldBeConstAnalyzer.cs b/src/Test/Utilities/Portable/Diagnostics/LocalCouldBeConstAnalyzer.cs index 38fb1ddee8879..f9743eef1c1eb 100644 --- a/src/Test/Utilities/Portable/Diagnostics/LocalCouldBeConstAnalyzer.cs +++ b/src/Test/Utilities/Portable/Diagnostics/LocalCouldBeConstAnalyzer.cs @@ -42,10 +42,10 @@ public sealed override void Initialize(AnalysisContext context) operationBlockContext.RegisterOperationAction( (operationContext) => { - IBaseAssignmentExpression assignment = (IBaseAssignmentExpression)operationContext.Operation; + IAssignmentExpression assignment = (IAssignmentExpression)operationContext.Operation; AssignTo(assignment.Target, assignedToLocals, mightBecomeConstLocals); }, - OperationKind.AssignmentExpression, + OperationKind.SimpleAssignmentExpression, OperationKind.CompoundAssignmentExpression, OperationKind.IncrementExpression); diff --git a/src/Test/Utilities/Portable/Diagnostics/OperationTestAnalyzer.cs b/src/Test/Utilities/Portable/Diagnostics/OperationTestAnalyzer.cs index 4bb91a6880fd3..d0915bf86d28b 100644 --- a/src/Test/Utilities/Portable/Diagnostics/OperationTestAnalyzer.cs +++ b/src/Test/Utilities/Portable/Diagnostics/OperationTestAnalyzer.cs @@ -161,9 +161,9 @@ public sealed override void Initialize(AnalysisContext context) if (forLoop.Before.Length == 1) { IOperation setup = forLoop.Before[0]; - if (setup.Kind == OperationKind.ExpressionStatement && ((IExpressionStatement)setup).Expression.Kind == OperationKind.AssignmentExpression) + if (setup.Kind == OperationKind.ExpressionStatement && ((IExpressionStatement)setup).Expression.Kind == OperationKind.SimpleAssignmentExpression) { - IAssignmentExpression setupAssignment = (IAssignmentExpression)((IExpressionStatement)setup).Expression; + ISimpleAssignmentExpression setupAssignment = (ISimpleAssignmentExpression)((IExpressionStatement)setup).Expression; if (setupAssignment.Target.Kind == OperationKind.LocalReferenceExpression && ((ILocalReferenceExpression)setupAssignment.Target).Local == testVariable && setupAssignment.Value.ConstantValue.HasValue && @@ -182,9 +182,9 @@ public sealed override void Initialize(AnalysisContext context) IOperation advanceIncrement = null; BinaryOperationKind advanceOperationCode = BinaryOperationKind.None; - if (advanceExpression.Kind == OperationKind.AssignmentExpression) + if (advanceExpression.Kind == OperationKind.SimpleAssignmentExpression) { - IAssignmentExpression advanceAssignment = (IAssignmentExpression)advanceExpression; + ISimpleAssignmentExpression advanceAssignment = (ISimpleAssignmentExpression)advanceExpression; if (advanceAssignment.Target.Kind == OperationKind.LocalReferenceExpression && ((ILocalReferenceExpression)advanceAssignment.Target).Local == testVariable && @@ -752,7 +752,7 @@ public sealed override void Initialize(AnalysisContext context) context.RegisterOperationAction( (operationContext) => { - var assignment = (IAssignmentExpression)operationContext.Operation; + var assignment = (ISimpleAssignmentExpression)operationContext.Operation; var kind = assignment.Target.Kind; if (kind == OperationKind.FieldReferenceExpression || kind == OperationKind.PropertyReferenceExpression) @@ -760,7 +760,7 @@ public sealed override void Initialize(AnalysisContext context) Report(operationContext, assignment.Syntax, DoNotUseMemberAssignmentDescriptor); } }, - OperationKind.AssignmentExpression); + OperationKind.SimpleAssignmentExpression); } private static void Report(OperationAnalysisContext context, SyntaxNode syntax, DiagnosticDescriptor descriptor) @@ -2068,7 +2068,7 @@ public sealed override void Initialize(AnalysisContext context) { operationContext.ReportDiagnostic(Diagnostic.Create(AssignmentOperationDescriptor, operationContext.Operation.Syntax.GetLocation())); }, - OperationKind.AssignmentExpression); + OperationKind.SimpleAssignmentExpression); context.RegisterSyntaxNodeAction( (syntaxContext) => From ba0c404164264ffd8788b221e1ac52fb870ab603 Mon Sep 17 00:00:00 2001 From: Heejae Chang Date: Mon, 26 Jun 2017 17:19:03 -0700 Subject: [PATCH 09/16] remove IndexedPropertyReference and merge it to PropertyReference --- .../Operations/CSharpOperationFactory.cs | 7 +- .../IOperation/IOperationTests_IArgument.cs | 14 +- .../Core/Portable/CodeAnalysis.csproj | 1 - .../Generated/Operations.xml.Generated.cs | 265 ++++++++---------- .../IIndexedPropertyReferenceExpression.cs | 18 -- .../IPropertyReferenceExpression.cs | 15 +- .../Core/Portable/Operations/OperationKind.cs | 2 - .../Portable/Operations/OperationVisitor.cs | 10 - .../Portable/Operations/OperationWalker.cs | 7 +- .../Core/Portable/PublicAPI.Unshipped.txt | 8 +- .../Operations/VisualBasicOperationFactory.vb | 13 +- .../Compilation/OperationTreeVerifier.cs | 28 +- .../Compilation/TestOperationWalker.cs | 8 - 13 files changed, 150 insertions(+), 246 deletions(-) delete mode 100644 src/Compilers/Core/Portable/Operations/IIndexedPropertyReferenceExpression.cs diff --git a/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs b/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs index f6fcc3f5a25ad..fdd7fd478bc45 100644 --- a/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs +++ b/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs @@ -266,15 +266,16 @@ private IPropertyReferenceExpression CreateBoundPropertyAccessOperation(BoundPro { IPropertySymbol property = boundPropertyAccess.PropertySymbol; Lazy instance = new Lazy(() => Create(boundPropertyAccess.PropertySymbol.IsStatic ? null : boundPropertyAccess.ReceiverOpt)); + Lazy> argumentsInEvaluationOrder = new Lazy>(() => ImmutableArray.Empty); ISymbol member = boundPropertyAccess.PropertySymbol; bool isInvalid = boundPropertyAccess.HasErrors; SyntaxNode syntax = boundPropertyAccess.Syntax; ITypeSymbol type = boundPropertyAccess.Type; Optional constantValue = ConvertToOptional(boundPropertyAccess.ConstantValue); - return new LazyPropertyReferenceExpression(property, instance, member, isInvalid, syntax, type, constantValue); + return new LazyPropertyReferenceExpression(property, instance, member, argumentsInEvaluationOrder, isInvalid, syntax, type, constantValue); } - private IIndexedPropertyReferenceExpression CreateBoundIndexerAccessOperation(BoundIndexerAccess boundIndexerAccess) + private IPropertyReferenceExpression CreateBoundIndexerAccessOperation(BoundIndexerAccess boundIndexerAccess) { IPropertySymbol property = boundIndexerAccess.Indexer; Lazy instance = new Lazy(() => Create(boundIndexerAccess.Indexer.IsStatic ? null : boundIndexerAccess.ReceiverOpt)); @@ -303,7 +304,7 @@ private IIndexedPropertyReferenceExpression CreateBoundIndexerAccessOperation(Bo SyntaxNode syntax = boundIndexerAccess.Syntax; ITypeSymbol type = boundIndexerAccess.Type; Optional constantValue = ConvertToOptional(boundIndexerAccess.ConstantValue); - return new LazyIndexedPropertyReferenceExpression(property, instance, member, argumentsInEvaluationOrder, isInvalid, syntax, type, constantValue); + return new LazyPropertyReferenceExpression(property, instance, member, argumentsInEvaluationOrder, isInvalid, syntax, type, constantValue); } private IEventReferenceExpression CreateBoundEventAccessOperation(BoundEventAccess boundEventAccess) diff --git a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IArgument.cs b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IArgument.cs index c4c6d7e68074e..ee4368b1b1bc8 100644 --- a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IArgument.cs +++ b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IArgument.cs @@ -1,5 +1,5 @@ // 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.Semantics; using Microsoft.CodeAnalysis.Test.Utilities; @@ -1260,7 +1260,7 @@ static void Main() string expectedOutput = @"1"; - VerifyOperationTreeAndDiagnosticsForTest(source, expectedOperationTree, expectedDiagnostics, AdditionalOperationTreeVerifier: IndexerAccessArgumentVerifier.Verify); + VerifyOperationTreeAndDiagnosticsForTest(source, expectedOperationTree, expectedDiagnostics, AdditionalOperationTreeVerifier: IndexerAccessArgumentVerifier.Verify); CompileAndVerify(new[] { source }, new[] { SystemRef }, expectedOutput: expectedOutput); } @@ -1324,7 +1324,7 @@ public void M() var expectedDiagnostics = DiagnosticDescription.None; VerifyOperationTreeAndDiagnosticsForTest(source, expectedOperationTree, expectedDiagnostics, AdditionalOperationTreeVerifier: IndexerAccessArgumentVerifier.Verify); - } + } [ClrOnlyFact(ClrOnlyReason.Ilasm)] public void AssigningToIndexer_UsingDefaultArgumentFromSetter() @@ -1408,7 +1408,7 @@ .property instance int32 Item(int32, int32) } // end of property P::Item } // end of class P -"; +"; var csharp = @" class C @@ -1724,9 +1724,9 @@ public static void Verify(IOperation operation, Compilation compilationIgnored, Instance.Visit(operation); } - public override void VisitIndexedPropertyReferenceExpression(IIndexedPropertyReferenceExpression operation) + public override void VisitPropertyReferenceExpression(IPropertyReferenceExpression operation) { - if (operation.IsInvalid) + if (operation.IsInvalid || operation.ArgumentsInEvaluationOrder.Length == 0) { return; } @@ -1742,5 +1742,5 @@ public override void VisitIndexedPropertyReferenceExpression(IIndexedPropertyRef } } } - } + } } \ No newline at end of file diff --git a/src/Compilers/Core/Portable/CodeAnalysis.csproj b/src/Compilers/Core/Portable/CodeAnalysis.csproj index 4d1293eb92fe1..40afe23ad89af 100644 --- a/src/Compilers/Core/Portable/CodeAnalysis.csproj +++ b/src/Compilers/Core/Portable/CodeAnalysis.csproj @@ -84,7 +84,6 @@ - diff --git a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs index 7f6e90281c816..ac4aa028eadee 100644 --- a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs +++ b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs @@ -1263,22 +1263,18 @@ public LazyEventAssignmentExpression(IEventSymbol @event, Lazy event /// /// Represents a reference to an event. /// - internal sealed partial class EventReferenceExpression : MemberReferenceExpression, IEventReferenceExpression + internal abstract partial class BaseEventReferenceExpression : MemberReferenceExpression, IEventReferenceExpression { - public EventReferenceExpression(IEventSymbol @event, IOperation instance, ISymbol member, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + public BaseEventReferenceExpression(IEventSymbol @event, ISymbol member, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(member, OperationKind.EventReferenceExpression, isInvalid, syntax, type, constantValue) { Event = @event; - Instance = instance; } /// /// Referenced event. /// public IEventSymbol Event { get; } - /// - /// Instance of the type. Null if the reference is to a static/shared member. - /// - public override IOperation Instance { get; } + public override void Accept(OperationVisitor visitor) { visitor.VisitEventReferenceExpression(this); @@ -1292,32 +1288,35 @@ public override TResult Accept(OperationVisitor /// Represents a reference to an event. /// - internal sealed partial class LazyEventReferenceExpression : MemberReferenceExpression, IEventReferenceExpression + internal sealed partial class EventReferenceExpression : BaseEventReferenceExpression, IEventReferenceExpression + { + public EventReferenceExpression(IEventSymbol @event, IOperation instance, ISymbol member, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(@event, member, isInvalid, syntax, type, constantValue) + { + Instance = instance; + } + /// + /// Instance of the type. Null if the reference is to a static/shared member. + /// + public override IOperation Instance { get; } + } + + /// + /// Represents a reference to an event. + /// + internal sealed partial class LazyEventReferenceExpression : BaseEventReferenceExpression, IEventReferenceExpression { private readonly Lazy _lazyInstance; - public LazyEventReferenceExpression(IEventSymbol @event, Lazy instance, ISymbol member, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(member, OperationKind.EventReferenceExpression, isInvalid, syntax, type, constantValue) + public LazyEventReferenceExpression(IEventSymbol @event, Lazy instance, ISymbol member, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(@event, member, isInvalid, syntax, type, constantValue) { - Event = @event; _lazyInstance = instance ?? throw new System.ArgumentNullException("instance"); } /// - /// Referenced event. - /// - public IEventSymbol Event { get; } - /// /// Instance of the type. Null if the reference is to a static/shared member. /// public override IOperation Instance => _lazyInstance.Value; - - public override void Accept(OperationVisitor visitor) - { - visitor.VisitEventReferenceExpression(this); - } - public override TResult Accept(OperationVisitor visitor, TArgument argument) - { - return visitor.VisitEventReferenceExpression(this, argument); - } } /// @@ -1433,22 +1432,18 @@ public override TResult Accept(OperationVisitor /// Represents a reference to a field. /// - internal sealed partial class FieldReferenceExpression : MemberReferenceExpression, IFieldReferenceExpression + internal abstract partial class BaseFieldReferenceExpression : MemberReferenceExpression, IFieldReferenceExpression { - public FieldReferenceExpression(IFieldSymbol field, IOperation instance, ISymbol member, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + public BaseFieldReferenceExpression(IFieldSymbol field, ISymbol member, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(member, OperationKind.FieldReferenceExpression, isInvalid, syntax, type, constantValue) { Field = field; - Instance = instance; } /// /// Referenced field. /// public IFieldSymbol Field { get; } - /// - /// Instance of the type. Null if the reference is to a static/shared member. - /// - public override IOperation Instance { get; } + public override void Accept(OperationVisitor visitor) { visitor.VisitFieldReferenceExpression(this); @@ -1462,32 +1457,35 @@ public override TResult Accept(OperationVisitor /// Represents a reference to a field. /// - internal sealed partial class LazyFieldReferenceExpression : MemberReferenceExpression, IFieldReferenceExpression + internal sealed partial class FieldReferenceExpression : BaseFieldReferenceExpression, IFieldReferenceExpression + { + public FieldReferenceExpression(IFieldSymbol field, IOperation instance, ISymbol member, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(field, member, isInvalid, syntax, type, constantValue) + { + Instance = instance; + } + /// + /// Instance of the type. Null if the reference is to a static/shared member. + /// + public override IOperation Instance { get; } + } + + /// + /// Represents a reference to a field. + /// + internal sealed partial class LazyFieldReferenceExpression : BaseFieldReferenceExpression, IFieldReferenceExpression { private readonly Lazy _lazyInstance; - public LazyFieldReferenceExpression(IFieldSymbol field, Lazy instance, ISymbol member, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(member, OperationKind.FieldReferenceExpression, isInvalid, syntax, type, constantValue) + public LazyFieldReferenceExpression(IFieldSymbol field, Lazy instance, ISymbol member, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(field, member, isInvalid, syntax, type, constantValue) { - Field = field; _lazyInstance = instance ?? throw new System.ArgumentNullException("instance"); } /// - /// Referenced field. - /// - public IFieldSymbol Field { get; } - /// /// Instance of the type. Null if the reference is to a static/shared member. /// public override IOperation Instance => _lazyInstance.Value; - - public override void Accept(OperationVisitor visitor) - { - visitor.VisitFieldReferenceExpression(this); - } - public override TResult Accept(OperationVisitor visitor, TArgument argument) - { - return visitor.VisitFieldReferenceExpression(this, argument); - } } /// @@ -1934,76 +1932,6 @@ public LazyIncrementExpression(UnaryOperationKind incrementOperationKind, Lazy - /// Represents a reference to an indexed property. - /// - internal sealed partial class IndexedPropertyReferenceExpression : BasePropertyReferenceExpression, IHasArgumentsExpression, IIndexedPropertyReferenceExpression - { - public IndexedPropertyReferenceExpression(IPropertySymbol property, IOperation instance, ISymbol member, ImmutableArray argumentsInEvaluationOrder, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(property, member, OperationKind.IndexedPropertyReferenceExpression, isInvalid, syntax, type, constantValue) - { - ArgumentsInEvaluationOrder = argumentsInEvaluationOrder; - Instance = instance; - } - /// - /// Arguments of the invocation, excluding the instance argument. Arguments are in evaluation order. - /// - /// - /// If the invocation is in its expanded form, then params/ParamArray arguments would be collected into arrays. - /// Default values are supplied for optional arguments missing in source. - /// - public ImmutableArray ArgumentsInEvaluationOrder { get; } - /// - /// Instance of the type. Null if the reference is to a static/shared member. - /// - public override IOperation Instance { get; } - public override void Accept(OperationVisitor visitor) - { - visitor.VisitIndexedPropertyReferenceExpression(this); - } - public override TResult Accept(OperationVisitor visitor, TArgument argument) - { - return visitor.VisitIndexedPropertyReferenceExpression(this, argument); - } - } - - /// - /// Represents a reference to an indexed property. - /// - internal sealed partial class LazyIndexedPropertyReferenceExpression : BasePropertyReferenceExpression, IHasArgumentsExpression, IIndexedPropertyReferenceExpression - { - private readonly Lazy _lazyInstance; - private readonly Lazy> _lazyArgumentsInEvaluationOrder; - - public LazyIndexedPropertyReferenceExpression(IPropertySymbol property, Lazy instance, ISymbol member, Lazy> argumentsInEvaluationOrder, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(property, member, OperationKind.IndexedPropertyReferenceExpression, isInvalid, syntax, type, constantValue) - { - _lazyArgumentsInEvaluationOrder = argumentsInEvaluationOrder; - _lazyInstance = instance ?? throw new System.ArgumentNullException("instance"); - } - /// - /// Arguments of the invocation, excluding the instance argument. Arguments are in evaluation order. - /// - /// - /// If the invocation is in its expanded form, then params/ParamArray arguments would be collected into arrays. - /// Default values are supplied for optional arguments missing in source. - /// - public ImmutableArray ArgumentsInEvaluationOrder => _lazyArgumentsInEvaluationOrder.Value; - - /// - /// Instance of the type. Null if the reference is to a static/shared member. - /// - public override IOperation Instance => _lazyInstance.Value; - - public override void Accept(OperationVisitor visitor) - { - visitor.VisitIndexedPropertyReferenceExpression(this); - } - public override TResult Accept(OperationVisitor visitor, TArgument argument) - { - return visitor.VisitIndexedPropertyReferenceExpression(this, argument); - } - } - /// /// Represents a C# this or base expression, or a VB Me, MyClass, or MyBase expression. /// @@ -2845,14 +2773,13 @@ protected MemberReferenceExpression(ISymbol member, OperationKind kind, bool isI /// /// Represents a reference to a method other than as the target of an invocation. /// - internal sealed partial class MethodBindingExpression : MemberReferenceExpression, IMethodBindingExpression + internal abstract partial class BaseMethodBindingExpression : MemberReferenceExpression, IMethodBindingExpression { - public MethodBindingExpression(IMethodSymbol method, bool isVirtual, IOperation instance, ISymbol member, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + public BaseMethodBindingExpression(IMethodSymbol method, bool isVirtual, ISymbol member, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(member, OperationKind.MethodBindingExpression, isInvalid, syntax, type, constantValue) { Method = method; IsVirtual = isVirtual; - Instance = instance; } /// /// Referenced method. @@ -2863,10 +2790,7 @@ public MethodBindingExpression(IMethodSymbol method, bool isVirtual, IOperation /// Indicates whether the reference uses virtual semantics. /// public bool IsVirtual { get; } - /// - /// Instance of the type. Null if the reference is to a static/shared member. - /// - public override IOperation Instance { get; } + public override void Accept(OperationVisitor visitor) { visitor.VisitMethodBindingExpression(this); @@ -2880,38 +2804,35 @@ public override TResult Accept(OperationVisitor /// Represents a reference to a method other than as the target of an invocation. /// - internal sealed partial class LazyMethodBindingExpression : MemberReferenceExpression, IMethodBindingExpression + internal sealed partial class MethodBindingExpression : BaseMethodBindingExpression, IMethodBindingExpression { - private readonly Lazy _lazyInstance; - - public LazyMethodBindingExpression(IMethodSymbol method, bool isVirtual, Lazy instance, ISymbol member, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(member, OperationKind.MethodBindingExpression, isInvalid, syntax, type, constantValue) + public MethodBindingExpression(IMethodSymbol method, bool isVirtual, IOperation instance, ISymbol member, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(method, isVirtual, member, isInvalid, syntax, type, constantValue) { - Method = method; - IsVirtual = isVirtual; - _lazyInstance = instance ?? throw new System.ArgumentNullException("instance"); + Instance = instance; } /// - /// Referenced method. + /// Instance of the type. Null if the reference is to a static/shared member. /// - public IMethodSymbol Method { get; } + public override IOperation Instance { get; } + } - /// - /// Indicates whether the reference uses virtual semantics. - /// - public bool IsVirtual { get; } + /// + /// Represents a reference to a method other than as the target of an invocation. + /// + internal sealed partial class LazyMethodBindingExpression : BaseMethodBindingExpression, IMethodBindingExpression + { + private readonly Lazy _lazyInstance; + + public LazyMethodBindingExpression(IMethodSymbol method, bool isVirtual, Lazy instance, ISymbol member, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(method, isVirtual, member, isInvalid, syntax, type, constantValue) + { + _lazyInstance = instance ?? throw new System.ArgumentNullException("instance"); + } /// /// Instance of the type. Null if the reference is to a static/shared member. /// public override IOperation Instance => _lazyInstance.Value; - - public override void Accept(OperationVisitor visitor) - { - visitor.VisitMethodBindingExpression(this); - } - public override TResult Accept(OperationVisitor visitor, TArgument argument) - { - return visitor.VisitMethodBindingExpression(this, argument); - } } /// @@ -3361,10 +3282,10 @@ public override TResult Accept(OperationVisitor /// Represents a reference to a property. /// - internal abstract partial class BasePropertyReferenceExpression : MemberReferenceExpression, IBasePropertyReferenceExpression + internal abstract partial class BasePropertyReferenceExpression : MemberReferenceExpression, IPropertyReferenceExpression, IHasArgumentsExpression { - protected BasePropertyReferenceExpression(IPropertySymbol property, ISymbol member, OperationKind kind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(member, kind, isInvalid, syntax, type, constantValue) + protected BasePropertyReferenceExpression(IPropertySymbol property, ISymbol member, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(member, OperationKind.PropertyReferenceExpression, isInvalid, syntax, type, constantValue) { Property = property; } @@ -3372,22 +3293,49 @@ protected BasePropertyReferenceExpression(IPropertySymbol property, ISymbol memb /// Referenced property. /// public IPropertySymbol Property { get; } + /// + /// Arguments of the invocation, excluding the instance argument. Arguments are in evaluation order. + /// + /// + /// If the invocation is in its expanded form, then params/ParamArray arguments would be collected into arrays. + /// Default values are supplied for optional arguments missing in source. + /// + public abstract ImmutableArray ArgumentsInEvaluationOrder { get; } + + public override void Accept(OperationVisitor visitor) + { + visitor.VisitPropertyReferenceExpression(this); + } + public override TResult Accept(OperationVisitor visitor, TArgument argument) + { + return visitor.VisitPropertyReferenceExpression(this, argument); + } } /// /// Represents a reference to a property. /// - internal sealed partial class PropertyReferenceExpression : BasePropertyReferenceExpression, IPropertyReferenceExpression + internal sealed partial class PropertyReferenceExpression : BasePropertyReferenceExpression, IPropertyReferenceExpression, IHasArgumentsExpression { - public PropertyReferenceExpression(IPropertySymbol property, IOperation instance, ISymbol member, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(property, member, OperationKind.PropertyReferenceExpression, isInvalid, syntax, type, constantValue) + public PropertyReferenceExpression(IPropertySymbol property, IOperation instance, ISymbol member, ImmutableArray argumentsInEvaluationOrder, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(property, member, isInvalid, syntax, type, constantValue) { Instance = instance; + ArgumentsInEvaluationOrder = argumentsInEvaluationOrder; } /// /// Instance of the type. Null if the reference is to a static/shared member. /// public override IOperation Instance { get; } + /// + /// Arguments of the invocation, excluding the instance argument. Arguments are in evaluation order. + /// + /// + /// If the invocation is in its expanded form, then params/ParamArray arguments would be collected into arrays. + /// Default values are supplied for optional arguments missing in source. + /// + public override ImmutableArray ArgumentsInEvaluationOrder { get; } + public override void Accept(OperationVisitor visitor) { visitor.VisitPropertyReferenceExpression(this); @@ -3401,18 +3349,29 @@ public override TResult Accept(OperationVisitor /// Represents a reference to a property. /// - internal sealed partial class LazyPropertyReferenceExpression : BasePropertyReferenceExpression, IPropertyReferenceExpression + internal sealed partial class LazyPropertyReferenceExpression : BasePropertyReferenceExpression, IPropertyReferenceExpression, IHasArgumentsExpression { private readonly Lazy _lazyInstance; + private readonly Lazy> _lazyArgumentsInEvaluationOrder; - public LazyPropertyReferenceExpression(IPropertySymbol property, Lazy instance, ISymbol member, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(property, member, OperationKind.PropertyReferenceExpression, isInvalid, syntax, type, constantValue) + public LazyPropertyReferenceExpression(IPropertySymbol property, Lazy instance, ISymbol member, Lazy> argumentsInEvaluationOrder, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(property, member, isInvalid, syntax, type, constantValue) { _lazyInstance = instance ?? throw new System.ArgumentNullException("instance"); + _lazyArgumentsInEvaluationOrder = argumentsInEvaluationOrder ?? throw new System.ArgumentNullException("argumentsInEvaluationOrder"); } /// /// Instance of the type. Null if the reference is to a static/shared member. /// public override IOperation Instance => _lazyInstance.Value; + /// + /// Arguments of the invocation, excluding the instance argument. Arguments are in evaluation order. + /// + /// + /// If the invocation is in its expanded form, then params/ParamArray arguments would be collected into arrays. + /// Default values are supplied for optional arguments missing in source. + /// + public override ImmutableArray ArgumentsInEvaluationOrder => _lazyArgumentsInEvaluationOrder.Value; public override void Accept(OperationVisitor visitor) { diff --git a/src/Compilers/Core/Portable/Operations/IIndexedPropertyReferenceExpression.cs b/src/Compilers/Core/Portable/Operations/IIndexedPropertyReferenceExpression.cs deleted file mode 100644 index 576b3fcb93138..0000000000000 --- a/src/Compilers/Core/Portable/Operations/IIndexedPropertyReferenceExpression.cs +++ /dev/null @@ -1,18 +0,0 @@ -// 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 System.Collections.Immutable; - -namespace Microsoft.CodeAnalysis.Semantics -{ - /// - /// Represents a reference to an indexed property. - /// - /// - /// This interface is reserved for implementation by its associated APIs. We reserve the right to - /// change it in the future. - /// - public interface IIndexedPropertyReferenceExpression : IBasePropertyReferenceExpression, IHasArgumentsExpression - { - } -} - diff --git a/src/Compilers/Core/Portable/Operations/IPropertyReferenceExpression.cs b/src/Compilers/Core/Portable/Operations/IPropertyReferenceExpression.cs index 341923c710609..98c0edd44e032 100644 --- a/src/Compilers/Core/Portable/Operations/IPropertyReferenceExpression.cs +++ b/src/Compilers/Core/Portable/Operations/IPropertyReferenceExpression.cs @@ -5,29 +5,18 @@ namespace Microsoft.CodeAnalysis.Semantics { /// - /// Represents a base interface for reference to a property. + /// Represents a reference to a property. /// /// /// This interface is reserved for implementation by its associated APIs. We reserve the right to /// change it in the future. /// - public interface IBasePropertyReferenceExpression : IMemberReferenceExpression + public interface IPropertyReferenceExpression : IMemberReferenceExpression, IHasArgumentsExpression { /// /// Referenced property. /// IPropertySymbol Property { get; } } - - /// - /// Represents a reference to a property. - /// - /// - /// This interface is reserved for implementation by its associated APIs. We reserve the right to - /// change it in the future. - /// - public interface IPropertyReferenceExpression : IBasePropertyReferenceExpression - { - } } diff --git a/src/Compilers/Core/Portable/Operations/OperationKind.cs b/src/Compilers/Core/Portable/Operations/OperationKind.cs index c7c5ab559d231..e38463c7dbcbf 100644 --- a/src/Compilers/Core/Portable/Operations/OperationKind.cs +++ b/src/Compilers/Core/Portable/Operations/OperationKind.cs @@ -88,8 +88,6 @@ public enum OperationKind MethodBindingExpression = 0x109, /// Indicates an . PropertyReferenceExpression = 0x10a, - /// Indicates an . - IndexedPropertyReferenceExpression = 0x10b, /// Indicates an . EventReferenceExpression = 0x10c, /// Indicates an . diff --git a/src/Compilers/Core/Portable/Operations/OperationVisitor.cs b/src/Compilers/Core/Portable/Operations/OperationVisitor.cs index e037da2394a04..b0928be05d690 100644 --- a/src/Compilers/Core/Portable/Operations/OperationVisitor.cs +++ b/src/Compilers/Core/Portable/Operations/OperationVisitor.cs @@ -245,11 +245,6 @@ public virtual void VisitPlaceholderExpression(IPlaceholderExpression operation) DefaultVisit(operation); } - public virtual void VisitIndexedPropertyReferenceExpression(IIndexedPropertyReferenceExpression operation) - { - DefaultVisit(operation); - } - public virtual void VisitUnaryOperatorExpression(IUnaryOperatorExpression operation) { DefaultVisit(operation); @@ -675,11 +670,6 @@ public virtual TResult VisitPlaceholderExpression(IPlaceholderExpression operati return DefaultVisit(operation, argument); } - public virtual TResult VisitIndexedPropertyReferenceExpression(IIndexedPropertyReferenceExpression operation, TArgument argument) - { - return DefaultVisit(operation, argument); - } - public virtual TResult VisitUnaryOperatorExpression(IUnaryOperatorExpression operation, TArgument argument) { return DefaultVisit(operation, argument); diff --git a/src/Compilers/Core/Portable/Operations/OperationWalker.cs b/src/Compilers/Core/Portable/Operations/OperationWalker.cs index 33ecbf6ccc9db..772b7bc6aee92 100644 --- a/src/Compilers/Core/Portable/Operations/OperationWalker.cs +++ b/src/Compilers/Core/Portable/Operations/OperationWalker.cs @@ -251,6 +251,7 @@ public override void VisitMethodBindingExpression(IMethodBindingExpression opera public override void VisitPropertyReferenceExpression(IPropertyReferenceExpression operation) { Visit(operation.Instance); + VisitArray(operation.ArgumentsInEvaluationOrder); } public override void VisitEventReferenceExpression(IEventReferenceExpression operation) @@ -278,12 +279,6 @@ public override void VisitPlaceholderExpression(IPlaceholderExpression operation { } - public override void VisitIndexedPropertyReferenceExpression(IIndexedPropertyReferenceExpression operation) - { - Visit(operation.Instance); - VisitArray(operation.ArgumentsInEvaluationOrder); - } - public override void VisitUnaryOperatorExpression(IUnaryOperatorExpression operation) { Visit(operation.Operand); diff --git a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt index b3486038b9776..b934609c6b6e4 100644 --- a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt +++ b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt @@ -83,7 +83,6 @@ Microsoft.CodeAnalysis.OperationKind.FieldReferenceExpression = 264 -> Microsoft Microsoft.CodeAnalysis.OperationKind.FixedStatement = 48 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.IfStatement = 5 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.IncrementExpression = 518 -> Microsoft.CodeAnalysis.OperationKind -Microsoft.CodeAnalysis.OperationKind.IndexedPropertyReferenceExpression = 267 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.InstanceReferenceExpression = 277 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.InterpolatedStringExpression = 286 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.InterpolatedStringText = 1037 -> Microsoft.CodeAnalysis.OperationKind @@ -355,8 +354,6 @@ Microsoft.CodeAnalysis.Semantics.IAssignmentExpression.Target.get -> Microsoft.C Microsoft.CodeAnalysis.Semantics.IAssignmentExpression.Value.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IAwaitExpression Microsoft.CodeAnalysis.Semantics.IAwaitExpression.AwaitedValue.get -> Microsoft.CodeAnalysis.IOperation -Microsoft.CodeAnalysis.Semantics.IBasePropertyReferenceExpression -Microsoft.CodeAnalysis.Semantics.IBasePropertyReferenceExpression.Property.get -> Microsoft.CodeAnalysis.IPropertySymbol Microsoft.CodeAnalysis.Semantics.IBinaryOperatorExpression Microsoft.CodeAnalysis.Semantics.IBinaryOperatorExpression.BinaryOperationKind.get -> Microsoft.CodeAnalysis.Semantics.BinaryOperationKind Microsoft.CodeAnalysis.Semantics.IBinaryOperatorExpression.LeftOperand.get -> Microsoft.CodeAnalysis.IOperation @@ -432,7 +429,6 @@ Microsoft.CodeAnalysis.Semantics.IIfStatement.IfTrueStatement.get -> Microsoft.C Microsoft.CodeAnalysis.Semantics.IIncrementExpression Microsoft.CodeAnalysis.Semantics.IIncrementExpression.IncrementOperationKind.get -> Microsoft.CodeAnalysis.Semantics.UnaryOperationKind Microsoft.CodeAnalysis.Semantics.IIncrementExpression.Target.get -> Microsoft.CodeAnalysis.IOperation -Microsoft.CodeAnalysis.Semantics.IIndexedPropertyReferenceExpression Microsoft.CodeAnalysis.Semantics.IInstanceReferenceExpression Microsoft.CodeAnalysis.Semantics.IInstanceReferenceExpression.InstanceReferenceKind.get -> Microsoft.CodeAnalysis.Semantics.InstanceReferenceKind Microsoft.CodeAnalysis.Semantics.IInterpolatedStringContent @@ -510,6 +506,7 @@ Microsoft.CodeAnalysis.Semantics.IPointerIndirectionReferenceExpression.Pointer. Microsoft.CodeAnalysis.Semantics.IPropertyInitializer Microsoft.CodeAnalysis.Semantics.IPropertyInitializer.InitializedProperty.get -> Microsoft.CodeAnalysis.IPropertySymbol Microsoft.CodeAnalysis.Semantics.IPropertyReferenceExpression +Microsoft.CodeAnalysis.Semantics.IPropertyReferenceExpression.Property.get -> Microsoft.CodeAnalysis.IPropertySymbol Microsoft.CodeAnalysis.Semantics.IRangeCaseClause Microsoft.CodeAnalysis.Semantics.IRangeCaseClause.MaximumValue.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IRangeCaseClause.MinimumValue.get -> Microsoft.CodeAnalysis.IOperation @@ -734,7 +731,6 @@ override Microsoft.CodeAnalysis.Semantics.OperationWalker.VisitForEachLoopStatem override Microsoft.CodeAnalysis.Semantics.OperationWalker.VisitForLoopStatement(Microsoft.CodeAnalysis.Semantics.IForLoopStatement operation) -> void override Microsoft.CodeAnalysis.Semantics.OperationWalker.VisitIfStatement(Microsoft.CodeAnalysis.Semantics.IIfStatement operation) -> void override Microsoft.CodeAnalysis.Semantics.OperationWalker.VisitIncrementExpression(Microsoft.CodeAnalysis.Semantics.IIncrementExpression operation) -> void -override Microsoft.CodeAnalysis.Semantics.OperationWalker.VisitIndexedPropertyReferenceExpression(Microsoft.CodeAnalysis.Semantics.IIndexedPropertyReferenceExpression operation) -> void override Microsoft.CodeAnalysis.Semantics.OperationWalker.VisitInstanceReferenceExpression(Microsoft.CodeAnalysis.Semantics.IInstanceReferenceExpression operation) -> void override Microsoft.CodeAnalysis.Semantics.OperationWalker.VisitInterpolatedStringExpression(Microsoft.CodeAnalysis.Semantics.IInterpolatedStringExpression operation) -> void override Microsoft.CodeAnalysis.Semantics.OperationWalker.VisitInterpolatedStringText(Microsoft.CodeAnalysis.Semantics.IInterpolatedStringText operation) -> void @@ -839,7 +835,6 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitForEachLoopStatem virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitForLoopStatement(Microsoft.CodeAnalysis.Semantics.IForLoopStatement operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitIfStatement(Microsoft.CodeAnalysis.Semantics.IIfStatement operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitIncrementExpression(Microsoft.CodeAnalysis.Semantics.IIncrementExpression operation) -> void -virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitIndexedPropertyReferenceExpression(Microsoft.CodeAnalysis.Semantics.IIndexedPropertyReferenceExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitInstanceReferenceExpression(Microsoft.CodeAnalysis.Semantics.IInstanceReferenceExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitInterpolatedStringExpression(Microsoft.CodeAnalysis.Semantics.IInterpolatedStringExpression operation) -> void virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitInterpolatedStringText(Microsoft.CodeAnalysis.Semantics.IInterpolatedStringText operation) -> void @@ -922,7 +917,6 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.Vi virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitForLoopStatement(Microsoft.CodeAnalysis.Semantics.IForLoopStatement operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitIfStatement(Microsoft.CodeAnalysis.Semantics.IIfStatement operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitIncrementExpression(Microsoft.CodeAnalysis.Semantics.IIncrementExpression operation, TArgument argument) -> TResult -virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitIndexedPropertyReferenceExpression(Microsoft.CodeAnalysis.Semantics.IIndexedPropertyReferenceExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitInstanceReferenceExpression(Microsoft.CodeAnalysis.Semantics.IInstanceReferenceExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitInterpolatedStringExpression(Microsoft.CodeAnalysis.Semantics.IInterpolatedStringExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitInterpolatedStringText(Microsoft.CodeAnalysis.Semantics.IInterpolatedStringText operation, TArgument argument) -> TResult diff --git a/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb b/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb index dcfc0373386f1..f530acf4228d5 100644 --- a/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb +++ b/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb @@ -520,7 +520,7 @@ Namespace Microsoft.CodeAnalysis.Semantics Return New LazyArrayInitializer(elementValues, isInvalid, syntax, type, constantValue) End Function - Private Function CreateBoundPropertyAccessOperation(boundPropertyAccess As BoundPropertyAccess) As IBasePropertyReferenceExpression + Private Function CreateBoundPropertyAccessOperation(boundPropertyAccess As BoundPropertyAccess) As IPropertyReferenceExpression Dim instance As Lazy(Of IOperation) = New Lazy(Of IOperation)( Function() If boundPropertyAccess.PropertySymbol.IsShared Then @@ -532,14 +532,17 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim [property] As IPropertySymbol = boundPropertyAccess.PropertySymbol Dim member As ISymbol = boundPropertyAccess.PropertySymbol - Dim argumentsInEvaluationOrder As Lazy(Of ImmutableArray(Of IArgument)) = New Lazy(Of ImmutableArray(Of IArgument))(Function() DeriveArguments(boundPropertyAccess.Arguments, boundPropertyAccess.PropertySymbol.Parameters)) + Dim argumentsInEvaluationOrder As Lazy(Of ImmutableArray(Of IArgument)) = New Lazy(Of ImmutableArray(Of IArgument))( + Function() + Return If(boundPropertyAccess.Arguments.Length = 0, + ImmutableArray(Of IArgument).Empty, + DeriveArguments(boundPropertyAccess.Arguments, boundPropertyAccess.PropertySymbol.Parameters)) + End Function) Dim isInvalid As Boolean = boundPropertyAccess.HasErrors Dim syntax As SyntaxNode = boundPropertyAccess.Syntax Dim type As ITypeSymbol = boundPropertyAccess.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundPropertyAccess.ConstantValueOpt) - Return If(boundPropertyAccess.Arguments.Length > 0, - DirectCast(New LazyIndexedPropertyReferenceExpression([property], instance, member, argumentsInEvaluationOrder, isInvalid, syntax, type, constantValue), IBasePropertyReferenceExpression), - New LazyPropertyReferenceExpression([property], instance, member, isInvalid, syntax, type, constantValue)) + Return New LazyPropertyReferenceExpression([property], instance, member, argumentsInEvaluationOrder, isInvalid, syntax, type, constantValue) End Function Private Function CreateBoundEventAccessOperation(boundEventAccess As BoundEventAccess) As IEventReferenceExpression diff --git a/src/Test/Utilities/Portable/Compilation/OperationTreeVerifier.cs b/src/Test/Utilities/Portable/Compilation/OperationTreeVerifier.cs index f07ab3c46f14f..06d4d5a886fb1 100644 --- a/src/Test/Utilities/Portable/Compilation/OperationTreeVerifier.cs +++ b/src/Test/Utilities/Portable/Compilation/OperationTreeVerifier.cs @@ -662,10 +662,22 @@ public override void VisitMethodBindingExpression(IMethodBindingExpression opera public override void VisitPropertyReferenceExpression(IPropertyReferenceExpression operation) { - LogString(nameof(IPropertyReferenceExpression)); - LogString($": {operation.Property.ToTestDisplayString()}"); + if (operation.ArgumentsInEvaluationOrder.Length > 0) + { + // keep existing logging behavior + LogString("IIndexedPropertyReferenceExpression"); + LogString($": {operation.Property.ToTestDisplayString()}"); - VisitMemberReferenceExpressionCommon(operation); + VisitMemberReferenceExpressionCommon(operation); + VisitArguments(operation); + } + else + { + LogString(nameof(IPropertyReferenceExpression)); + LogString($": {operation.Property.ToTestDisplayString()}"); + + VisitMemberReferenceExpressionCommon(operation); + } } public override void VisitEventReferenceExpression(IEventReferenceExpression operation) @@ -713,16 +725,6 @@ public override void VisitPlaceholderExpression(IPlaceholderExpression operation base.VisitPlaceholderExpression(operation); } - public override void VisitIndexedPropertyReferenceExpression(IIndexedPropertyReferenceExpression operation) - { - LogString(nameof(IIndexedPropertyReferenceExpression)); - - LogString($": {operation.Property.ToTestDisplayString()}"); - - VisitMemberReferenceExpressionCommon(operation); - VisitArguments(operation); - } - public override void VisitUnaryOperatorExpression(IUnaryOperatorExpression operation) { LogString(nameof(IUnaryOperatorExpression)); diff --git a/src/Test/Utilities/Portable/Compilation/TestOperationWalker.cs b/src/Test/Utilities/Portable/Compilation/TestOperationWalker.cs index 032512364f342..97cc7ad90b072 100644 --- a/src/Test/Utilities/Portable/Compilation/TestOperationWalker.cs +++ b/src/Test/Utilities/Portable/Compilation/TestOperationWalker.cs @@ -319,14 +319,6 @@ public override void VisitPlaceholderExpression(IPlaceholderExpression operation base.VisitPlaceholderExpression(operation); } - public override void VisitIndexedPropertyReferenceExpression(IIndexedPropertyReferenceExpression operation) - { - var member = operation.Member; - var property = operation.Property; - - base.VisitIndexedPropertyReferenceExpression(operation); - } - public override void VisitUnaryOperatorExpression(IUnaryOperatorExpression operation) { var usesOperatorMethod = operation.UsesOperatorMethod; From 95974858e5be25ad90a73afde66718ff29bdacb7 Mon Sep 17 00:00:00 2001 From: Heejae Chang Date: Mon, 26 Jun 2017 17:31:35 -0700 Subject: [PATCH 10/16] made CaseClause to follow same pattern --- .../Generated/Operations.xml.Generated.cs | 140 ++++++++++-------- 1 file changed, 79 insertions(+), 61 deletions(-) diff --git a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs index ac4aa028eadee..4fc2a2c8db11f 100644 --- a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs +++ b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs @@ -3386,22 +3386,21 @@ public override TResult Accept(OperationVisitor /// Represents Case x To y in VB. /// - internal sealed partial class RangeCaseClause : CaseClause, IRangeCaseClause + internal abstract partial class BaseRangeCaseClause : CaseClause, IRangeCaseClause { - public RangeCaseClause(IOperation minimumValue, IOperation maximumValue, CaseKind caseKind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + public BaseRangeCaseClause(CaseKind caseKind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(caseKind, OperationKind.RangeCaseClause, isInvalid, syntax, type, constantValue) { - MinimumValue = minimumValue; - MaximumValue = maximumValue; } /// /// Minimum value of the case range. /// - public IOperation MinimumValue { get; } + public abstract IOperation MinimumValue { get; } /// /// Maximum value of the case range. /// - public IOperation MaximumValue { get; } + public abstract IOperation MaximumValue { get; } + public override void Accept(OperationVisitor visitor) { visitor.VisitRangeCaseClause(this); @@ -3415,12 +3414,34 @@ public override TResult Accept(OperationVisitor /// Represents Case x To y in VB. /// - internal sealed partial class LazyRangeCaseClause : CaseClause, IRangeCaseClause + internal sealed partial class RangeCaseClause : BaseRangeCaseClause, IRangeCaseClause + { + public RangeCaseClause(IOperation minimumValue, IOperation maximumValue, CaseKind caseKind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(caseKind, isInvalid, syntax, type, constantValue) + { + MinimumValue = minimumValue; + MaximumValue = maximumValue; + } + /// + /// Minimum value of the case range. + /// + public override IOperation MinimumValue { get; } + /// + /// Maximum value of the case range. + /// + public override IOperation MaximumValue { get; } + } + + /// + /// Represents Case x To y in VB. + /// + internal sealed partial class LazyRangeCaseClause : BaseRangeCaseClause, IRangeCaseClause { private readonly Lazy _lazyMinimumValue; private readonly Lazy _lazyMaximumValue; - public LazyRangeCaseClause(Lazy minimumValue, Lazy maximumValue, CaseKind caseKind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(caseKind, OperationKind.RangeCaseClause, isInvalid, syntax, type, constantValue) + public LazyRangeCaseClause(Lazy minimumValue, Lazy maximumValue, CaseKind caseKind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(caseKind, isInvalid, syntax, type, constantValue) { _lazyMinimumValue = minimumValue ?? throw new System.ArgumentNullException("minimumValue"); _lazyMaximumValue = maximumValue ?? throw new System.ArgumentNullException("maximumValue"); @@ -3428,42 +3449,33 @@ public LazyRangeCaseClause(Lazy minimumValue, Lazy maxim /// /// Minimum value of the case range. /// - public IOperation MinimumValue => _lazyMinimumValue.Value; + public override IOperation MinimumValue => _lazyMinimumValue.Value; /// /// Maximum value of the case range. /// - public IOperation MaximumValue => _lazyMaximumValue.Value; - - public override void Accept(OperationVisitor visitor) - { - visitor.VisitRangeCaseClause(this); - } - public override TResult Accept(OperationVisitor visitor, TArgument argument) - { - return visitor.VisitRangeCaseClause(this, argument); - } + public override IOperation MaximumValue => _lazyMaximumValue.Value; } /// /// Represents Case Is op x in VB. /// - internal sealed partial class RelationalCaseClause : CaseClause, IRelationalCaseClause + internal abstract partial class BaseRelationalCaseClause : CaseClause, IRelationalCaseClause { - public RelationalCaseClause(IOperation value, BinaryOperationKind relation, CaseKind caseKind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + public BaseRelationalCaseClause(BinaryOperationKind relation, CaseKind caseKind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(caseKind, OperationKind.RelationalCaseClause, isInvalid, syntax, type, constantValue) { - Value = value; Relation = relation; } /// /// Case value. /// - public IOperation Value { get; } + public abstract IOperation Value { get; } /// /// Relational operator used to compare the switch value with the case value. /// public BinaryOperationKind Relation { get; } + public override void Accept(OperationVisitor visitor) { visitor.VisitRelationalCaseClause(this); @@ -3477,32 +3489,35 @@ public override TResult Accept(OperationVisitor /// Represents Case Is op x in VB. /// - internal sealed partial class LazyRelationalCaseClause : CaseClause, IRelationalCaseClause + internal sealed partial class RelationalCaseClause : BaseRelationalCaseClause, IRelationalCaseClause { - private readonly Lazy _lazyValue; - - public LazyRelationalCaseClause(Lazy value, BinaryOperationKind relation, CaseKind caseKind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(caseKind, OperationKind.RelationalCaseClause, isInvalid, syntax, type, constantValue) + public RelationalCaseClause(IOperation value, BinaryOperationKind relation, CaseKind caseKind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(relation, caseKind, isInvalid, syntax, type, constantValue) { - _lazyValue = value ?? throw new System.ArgumentNullException("value"); - Relation = relation; + Value = value; } /// /// Case value. /// - public IOperation Value => _lazyValue.Value; + public override IOperation Value { get; } + } - /// - /// Relational operator used to compare the switch value with the case value. - /// - public BinaryOperationKind Relation { get; } - public override void Accept(OperationVisitor visitor) - { - visitor.VisitRelationalCaseClause(this); - } - public override TResult Accept(OperationVisitor visitor, TArgument argument) + /// + /// Represents Case Is op x in VB. + /// + internal sealed partial class LazyRelationalCaseClause : BaseRelationalCaseClause, IRelationalCaseClause + { + private readonly Lazy _lazyValue; + + public LazyRelationalCaseClause(Lazy value, BinaryOperationKind relation, CaseKind caseKind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(relation, caseKind, isInvalid, syntax, type, constantValue) { - return visitor.VisitRelationalCaseClause(this, argument); + _lazyValue = value ?? throw new System.ArgumentNullException("value"); } + /// + /// Case value. + /// + public override IOperation Value => _lazyValue.Value; } /// @@ -3581,22 +3596,22 @@ public LazyReturnStatement(OperationKind kind, Lazy returnedValue, b /// /// Represents case x in C# or Case x in VB. /// - internal sealed partial class SingleValueCaseClause : CaseClause, ISingleValueCaseClause + internal abstract partial class BaseSingleValueCaseClause : CaseClause, ISingleValueCaseClause { - public SingleValueCaseClause(IOperation value, BinaryOperationKind equality, CaseKind caseKind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + public BaseSingleValueCaseClause(BinaryOperationKind equality, CaseKind caseKind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(caseKind, OperationKind.SingleValueCaseClause, isInvalid, syntax, type, constantValue) { - Value = value; Equality = equality; } /// /// Case value. /// - public IOperation Value { get; } + public abstract IOperation Value { get; } /// /// Relational operator used to compare the switch value with the case value. /// public BinaryOperationKind Equality { get; } + public override void Accept(OperationVisitor visitor) { visitor.VisitSingleValueCaseClause(this); @@ -3610,32 +3625,35 @@ public override TResult Accept(OperationVisitor /// Represents case x in C# or Case x in VB. /// - internal sealed partial class LazySingleValueCaseClause : CaseClause, ISingleValueCaseClause + internal sealed partial class SingleValueCaseClause : BaseSingleValueCaseClause, ISingleValueCaseClause { - private readonly Lazy _lazyValue; - - public LazySingleValueCaseClause(Lazy value, BinaryOperationKind equality, CaseKind caseKind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(caseKind, OperationKind.SingleValueCaseClause, isInvalid, syntax, type, constantValue) + public SingleValueCaseClause(IOperation value, BinaryOperationKind equality, CaseKind caseKind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(equality, caseKind, isInvalid, syntax, type, constantValue) { - _lazyValue = value ?? throw new System.ArgumentNullException("value"); - Equality = equality; + Value = value; } /// /// Case value. /// - public IOperation Value => _lazyValue.Value; + public override IOperation Value { get; } + } - /// - /// Relational operator used to compare the switch value with the case value. - /// - public BinaryOperationKind Equality { get; } - public override void Accept(OperationVisitor visitor) - { - visitor.VisitSingleValueCaseClause(this); - } - public override TResult Accept(OperationVisitor visitor, TArgument argument) + /// + /// Represents case x in C# or Case x in VB. + /// + internal sealed partial class LazySingleValueCaseClause : BaseSingleValueCaseClause, ISingleValueCaseClause + { + private readonly Lazy _lazyValue; + + public LazySingleValueCaseClause(Lazy value, BinaryOperationKind equality, CaseKind caseKind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(equality, caseKind, isInvalid, syntax, type, constantValue) { - return visitor.VisitSingleValueCaseClause(this, argument); + _lazyValue = value ?? throw new System.ArgumentNullException("value"); } + /// + /// Case value. + /// + public override IOperation Value => _lazyValue.Value; } /// From ece36be588ae4bbe68978f05ec64cdb3bfd39717 Mon Sep 17 00:00:00 2001 From: Heejae Chang Date: Mon, 26 Jun 2017 18:02:21 -0700 Subject: [PATCH 11/16] made symbol initializer to follow same pattern --- .../Generated/Operations.xml.Generated.cs | 291 +++++++++--------- 1 file changed, 149 insertions(+), 142 deletions(-) diff --git a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs index 4fc2a2c8db11f..9bc2a260826f5 100644 --- a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs +++ b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs @@ -1378,19 +1378,18 @@ public LazyExpressionStatement(Lazy expression, bool isInvalid, Synt /// /// Represents an initialization of a field. /// - internal sealed partial class FieldInitializer : SymbolInitializer, IFieldInitializer + internal abstract partial class BaseFieldInitializer : SymbolInitializer, IFieldInitializer { - public FieldInitializer(ImmutableArray initializedFields, IOperation value, OperationKind kind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + public BaseFieldInitializer(ImmutableArray initializedFields, OperationKind kind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(kind, isInvalid, syntax, type, constantValue) { InitializedFields = initializedFields; - Value = value; } /// /// Initialized fields. There can be multiple fields for Visual Basic fields declared with As New. /// public ImmutableArray InitializedFields { get; } - public override IOperation Value { get; } + public override void Accept(OperationVisitor visitor) { visitor.VisitFieldInitializer(this); @@ -1404,29 +1403,29 @@ public override TResult Accept(OperationVisitor /// Represents an initialization of a field. /// - internal sealed partial class LazyFieldInitializer : SymbolInitializer, IFieldInitializer + internal sealed partial class FieldInitializer : BaseFieldInitializer, IFieldInitializer + { + public FieldInitializer(ImmutableArray initializedFields, IOperation value, OperationKind kind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(initializedFields, kind, isInvalid, syntax, type, constantValue) + { + Value = value; + } + public override IOperation Value { get; } + } + + /// + /// Represents an initialization of a field. + /// + internal sealed partial class LazyFieldInitializer : BaseFieldInitializer, IFieldInitializer { private readonly Lazy _lazyValue; - public LazyFieldInitializer(ImmutableArray initializedFields, Lazy value, OperationKind kind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(kind, isInvalid, syntax, type, constantValue) + public LazyFieldInitializer(ImmutableArray initializedFields, Lazy value, OperationKind kind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(initializedFields, kind, isInvalid, syntax, type, constantValue) { - InitializedFields = initializedFields; _lazyValue = value ?? throw new System.ArgumentNullException("value"); } - /// - /// Initialized fields. There can be multiple fields for Visual Basic fields declared with As New. - /// - public ImmutableArray InitializedFields { get; } public override IOperation Value => _lazyValue.Value; - - public override void Accept(OperationVisitor visitor) - { - visitor.VisitFieldInitializer(this); - } - public override TResult Accept(OperationVisitor visitor, TArgument argument) - { - return visitor.VisitFieldInitializer(this, argument); - } } /// @@ -1563,14 +1562,12 @@ public LazyFixedStatement(Lazy variables, Lazy /// Represents a C# foreach statement or a VB For Each statement. /// - internal sealed partial class ForEachLoopStatement : LoopStatement, IForEachLoopStatement + internal abstract partial class BaseForEachLoopStatement : LoopStatement, IForEachLoopStatement { - public ForEachLoopStatement(ILocalSymbol iterationVariable, IOperation collection, LoopKind loopKind, IOperation body, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + public BaseForEachLoopStatement(ILocalSymbol iterationVariable, LoopKind loopKind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(loopKind, OperationKind.LoopStatement, isInvalid, syntax, type, constantValue) { IterationVariable = iterationVariable; - Collection = collection; - Body = body; } /// /// Iteration variable of the loop. @@ -1579,11 +1576,8 @@ public ForEachLoopStatement(ILocalSymbol iterationVariable, IOperation collectio /// /// Collection value over which the loop iterates. /// - public IOperation Collection { get; } - /// - /// Body of the loop. - /// - public override IOperation Body { get; } + public abstract IOperation Collection { get; } + public override void Accept(OperationVisitor visitor) { visitor.VisitForEachLoopStatement(this); @@ -1597,48 +1591,87 @@ public override TResult Accept(OperationVisitor /// Represents a C# foreach statement or a VB For Each statement. /// - internal sealed partial class LazyForEachLoopStatement : LoopStatement, IForEachLoopStatement + internal sealed partial class ForEachLoopStatement : BaseForEachLoopStatement, IForEachLoopStatement + { + public ForEachLoopStatement(ILocalSymbol iterationVariable, IOperation collection, LoopKind loopKind, IOperation body, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(iterationVariable, loopKind, isInvalid, syntax, type, constantValue) + { + Collection = collection; + Body = body; + } + /// + /// Collection value over which the loop iterates. + /// + public override IOperation Collection { get; } + /// + /// Body of the loop. + /// + public override IOperation Body { get; } + } + + /// + /// Represents a C# foreach statement or a VB For Each statement. + /// + internal sealed partial class LazyForEachLoopStatement : BaseForEachLoopStatement, IForEachLoopStatement { private readonly Lazy _lazyCollection; private readonly Lazy _lazyBody; - public LazyForEachLoopStatement(ILocalSymbol iterationVariable, Lazy collection, LoopKind loopKind, Lazy body, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(loopKind, OperationKind.LoopStatement, isInvalid, syntax, type, constantValue) + public LazyForEachLoopStatement(ILocalSymbol iterationVariable, Lazy collection, LoopKind loopKind, Lazy body, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(iterationVariable, loopKind, isInvalid, syntax, type, constantValue) { - IterationVariable = iterationVariable; _lazyCollection = collection ?? throw new System.ArgumentNullException("collection"); _lazyBody = body ?? throw new System.ArgumentNullException("body"); } /// - /// Iteration variable of the loop. - /// - public ILocalSymbol IterationVariable { get; } - /// /// Collection value over which the loop iterates. /// - public IOperation Collection => _lazyCollection.Value; - + public override IOperation Collection => _lazyCollection.Value; /// /// Body of the loop. /// public override IOperation Body => _lazyBody.Value; + } + + /// + /// Represents a C# for statement or a VB For statement. + /// + internal abstract partial class BaseForLoopStatement : ForWhileUntilLoopStatement, IForLoopStatement + { + public BaseForLoopStatement(LoopKind loopKind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(loopKind, OperationKind.LoopStatement, isInvalid, syntax, type, constantValue) + { + } + /// + /// Statements to execute before entry to the loop. For C# these come from the first clause of the for statement. For VB these initialize the index variable of the For statement. + /// + public abstract ImmutableArray Before { get; } + /// + /// Statements to execute at the bottom of the loop. For C# these come from the third clause of the for statement. For VB these increment the index variable of the For statement. + /// + public abstract ImmutableArray AtLoopBottom { get; } + /// + /// Declarations local to the loop. + /// + public abstract ImmutableArray Locals { get; } public override void Accept(OperationVisitor visitor) { - visitor.VisitForEachLoopStatement(this); + visitor.VisitForLoopStatement(this); } public override TResult Accept(OperationVisitor visitor, TArgument argument) { - return visitor.VisitForEachLoopStatement(this, argument); + return visitor.VisitForLoopStatement(this, argument); } } /// /// Represents a C# for statement or a VB For statement. /// - internal sealed partial class ForLoopStatement : ForWhileUntilLoopStatement, IForLoopStatement + internal sealed partial class ForLoopStatement : BaseForLoopStatement, IForLoopStatement { public ForLoopStatement(ImmutableArray before, ImmutableArray atLoopBottom, ImmutableArray locals, IOperation condition, LoopKind loopKind, IOperation body, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(loopKind, OperationKind.LoopStatement, isInvalid, syntax, type, constantValue) + base(loopKind, isInvalid, syntax, type, constantValue) { Before = before; AtLoopBottom = atLoopBottom; @@ -1649,15 +1682,15 @@ public ForLoopStatement(ImmutableArray before, ImmutableArray /// Statements to execute before entry to the loop. For C# these come from the first clause of the for statement. For VB these initialize the index variable of the For statement. /// - public ImmutableArray Before { get; } + public override ImmutableArray Before { get; } /// /// Statements to execute at the bottom of the loop. For C# these come from the third clause of the for statement. For VB these increment the index variable of the For statement. /// - public ImmutableArray AtLoopBottom { get; } + public override ImmutableArray AtLoopBottom { get; } /// /// Declarations local to the loop. /// - public ImmutableArray Locals { get; } + public override ImmutableArray Locals { get; } /// /// Condition of the loop. /// @@ -1666,27 +1699,20 @@ public ForLoopStatement(ImmutableArray before, ImmutableArray public override IOperation Body { get; } - public override void Accept(OperationVisitor visitor) - { - visitor.VisitForLoopStatement(this); - } - public override TResult Accept(OperationVisitor visitor, TArgument argument) - { - return visitor.VisitForLoopStatement(this, argument); - } } /// /// Represents a C# for statement or a VB For statement. /// - internal sealed partial class LazyForLoopStatement : ForWhileUntilLoopStatement, IForLoopStatement + internal sealed partial class LazyForLoopStatement : BaseForLoopStatement, IForLoopStatement { private readonly Lazy> _lazyBefore; private readonly Lazy> _lazyAtLoopBottom; private readonly Lazy _lazyCondition; private readonly Lazy _lazyBody; - public LazyForLoopStatement(Lazy> before, Lazy> atLoopBottom, ImmutableArray locals, Lazy condition, LoopKind loopKind, Lazy body, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(loopKind, OperationKind.LoopStatement, isInvalid, syntax, type, constantValue) + public LazyForLoopStatement(Lazy> before, Lazy> atLoopBottom, ImmutableArray locals, Lazy condition, LoopKind loopKind, Lazy body, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(loopKind, isInvalid, syntax, type, constantValue) { _lazyBefore = before; _lazyAtLoopBottom = atLoopBottom; @@ -1697,17 +1723,17 @@ public LazyForLoopStatement(Lazy> before, Lazy /// Statements to execute before entry to the loop. For C# these come from the first clause of the for statement. For VB these initialize the index variable of the For statement. /// - public ImmutableArray Before => _lazyBefore.Value; + public override ImmutableArray Before => _lazyBefore.Value; /// /// Statements to execute at the bottom of the loop. For C# these come from the third clause of the for statement. For VB these increment the index variable of the For statement. /// - public ImmutableArray AtLoopBottom => _lazyAtLoopBottom.Value; + public override ImmutableArray AtLoopBottom => _lazyAtLoopBottom.Value; /// /// Declarations local to the loop. /// - public ImmutableArray Locals { get; } + public override ImmutableArray Locals { get; } /// /// Condition of the loop. /// @@ -1717,15 +1743,6 @@ public LazyForLoopStatement(Lazy> before, Lazy public override IOperation Body => _lazyBody.Value; - - public override void Accept(OperationVisitor visitor) - { - visitor.VisitForLoopStatement(this); - } - public override TResult Accept(OperationVisitor visitor, TArgument argument) - { - return visitor.VisitForLoopStatement(this, argument); - } } /// @@ -3018,19 +3035,17 @@ public override TResult Accept(OperationVisitor /// Represents an initialization of a parameter at the point of declaration. /// - internal sealed partial class ParameterInitializer : SymbolInitializer, IParameterInitializer + internal abstract partial class BaseParameterInitializer : SymbolInitializer, IParameterInitializer { - public ParameterInitializer(IParameterSymbol parameter, IOperation value, OperationKind kind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + public BaseParameterInitializer(IParameterSymbol parameter, OperationKind kind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(kind, isInvalid, syntax, type, constantValue) { - Parameter = parameter; - Value = value; } /// /// Initialized parameter. /// public IParameterSymbol Parameter { get; } - public override IOperation Value { get; } + public override void Accept(OperationVisitor visitor) { visitor.VisitParameterInitializer(this); @@ -3044,29 +3059,29 @@ public override TResult Accept(OperationVisitor /// Represents an initialization of a parameter at the point of declaration. /// - internal sealed partial class LazyParameterInitializer : SymbolInitializer, IParameterInitializer + internal sealed partial class ParameterInitializer : BaseParameterInitializer, IParameterInitializer + { + public ParameterInitializer(IParameterSymbol parameter, IOperation value, OperationKind kind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(parameter, kind, isInvalid, syntax, type, constantValue) + { + Value = value; + } + public override IOperation Value { get; } + } + + /// + /// Represents an initialization of a parameter at the point of declaration. + /// + internal sealed partial class LazyParameterInitializer : BaseParameterInitializer, IParameterInitializer { private readonly Lazy _lazyValue; - public LazyParameterInitializer(IParameterSymbol parameter, Lazy value, OperationKind kind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(kind, isInvalid, syntax, type, constantValue) + public LazyParameterInitializer(IParameterSymbol parameter, Lazy value, OperationKind kind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(parameter, kind, isInvalid, syntax, type, constantValue) { - Parameter = parameter; _lazyValue = value ?? throw new System.ArgumentNullException("value"); } - /// - /// Initialized parameter. - /// - public IParameterSymbol Parameter { get; } public override IOperation Value => _lazyValue.Value; - - public override void Accept(OperationVisitor visitor) - { - visitor.VisitParameterInitializer(this); - } - public override TResult Accept(OperationVisitor visitor, TArgument argument) - { - return visitor.VisitParameterInitializer(this, argument); - } } /// @@ -3228,19 +3243,18 @@ public LazyPointerIndirectionReferenceExpression(Lazy pointer, bool /// /// Represents an initialization of a property. /// - internal sealed partial class PropertyInitializer : SymbolInitializer, IPropertyInitializer + internal abstract partial class BasePropertyInitializer : SymbolInitializer, IPropertyInitializer { - public PropertyInitializer(IPropertySymbol initializedProperty, IOperation value, OperationKind kind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + public BasePropertyInitializer(IPropertySymbol initializedProperty, OperationKind kind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(kind, isInvalid, syntax, type, constantValue) { InitializedProperty = initializedProperty; - Value = value; } /// /// Set method used to initialize the property. /// public IPropertySymbol InitializedProperty { get; } - public override IOperation Value { get; } + public override void Accept(OperationVisitor visitor) { visitor.VisitPropertyInitializer(this); @@ -3254,29 +3268,29 @@ public override TResult Accept(OperationVisitor /// Represents an initialization of a property. /// - internal sealed partial class LazyPropertyInitializer : SymbolInitializer, IPropertyInitializer + internal sealed partial class PropertyInitializer : BasePropertyInitializer, IPropertyInitializer + { + public PropertyInitializer(IPropertySymbol initializedProperty, IOperation value, OperationKind kind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(initializedProperty, kind, isInvalid, syntax, type, constantValue) + { + Value = value; + } + public override IOperation Value { get; } + } + + /// + /// Represents an initialization of a property. + /// + internal sealed partial class LazyPropertyInitializer : BasePropertyInitializer, IPropertyInitializer { private readonly Lazy _lazyValue; - public LazyPropertyInitializer(IPropertySymbol initializedProperty, Lazy value, OperationKind kind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(kind, isInvalid, syntax, type, constantValue) + public LazyPropertyInitializer(IPropertySymbol initializedProperty, Lazy value, OperationKind kind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(initializedProperty, kind, isInvalid, syntax, type, constantValue) { - InitializedProperty = initializedProperty; _lazyValue = value ?? throw new System.ArgumentNullException("value"); } - /// - /// Set method used to initialize the property. - /// - public IPropertySymbol InitializedProperty { get; } public override IOperation Value => _lazyValue.Value; - - public override void Accept(OperationVisitor visitor) - { - visitor.VisitPropertyInitializer(this); - } - public override TResult Accept(OperationVisitor visitor, TArgument argument) - { - return visitor.VisitPropertyInitializer(this, argument); - } } /// @@ -4397,15 +4411,13 @@ public LazyVariableDeclarationStatement(Lazy /// Represents a C# while or do statement, or a VB While or Do statement. /// - internal sealed partial class WhileUntilLoopStatement : ForWhileUntilLoopStatement, IWhileUntilLoopStatement + internal abstract partial class BaseWhileUntilLoopStatement : ForWhileUntilLoopStatement, IWhileUntilLoopStatement { - public WhileUntilLoopStatement(bool isTopTest, bool isWhile, IOperation condition, LoopKind loopKind, IOperation body, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + public BaseWhileUntilLoopStatement(bool isTopTest, bool isWhile, LoopKind loopKind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(loopKind, OperationKind.LoopStatement, isInvalid, syntax, type, constantValue) { IsTopTest = isTopTest; IsWhile = isWhile; - Condition = condition; - Body = body; } /// /// True if the loop test executes at the top of the loop; false if the loop test executes at the bottom of the loop. @@ -4415,14 +4427,7 @@ public WhileUntilLoopStatement(bool isTopTest, bool isWhile, IOperation conditio /// True if the loop is a while loop; false if the loop is an until loop. /// public bool IsWhile { get; } - /// - /// Condition of the loop. - /// - public override IOperation Condition { get; } - /// - /// Body of the loop. - /// - public override IOperation Body { get; } + public override void Accept(OperationVisitor visitor) { visitor.VisitWhileUntilLoopStatement(this); @@ -4436,44 +4441,46 @@ public override TResult Accept(OperationVisitor /// Represents a C# while or do statement, or a VB While or Do statement. /// - internal sealed partial class LazyWhileUntilLoopStatement : ForWhileUntilLoopStatement, IWhileUntilLoopStatement + internal sealed partial class WhileUntilLoopStatement : BaseWhileUntilLoopStatement, IWhileUntilLoopStatement + { + public WhileUntilLoopStatement(bool isTopTest, bool isWhile, IOperation condition, LoopKind loopKind, IOperation body, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(isTopTest, isWhile, loopKind, isInvalid, syntax, type, constantValue) + { + Condition = condition; + Body = body; + } + /// + /// Condition of the loop. + /// + public override IOperation Condition { get; } + /// + /// Body of the loop. + /// + public override IOperation Body { get; } + } + + /// + /// Represents a C# while or do statement, or a VB While or Do statement. + /// + internal sealed partial class LazyWhileUntilLoopStatement : BaseWhileUntilLoopStatement, IWhileUntilLoopStatement { private readonly Lazy _lazyCondition; private readonly Lazy _lazyBody; - public LazyWhileUntilLoopStatement(bool isTopTest, bool isWhile, Lazy condition, LoopKind loopKind, Lazy body, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(loopKind, OperationKind.LoopStatement, isInvalid, syntax, type, constantValue) + public LazyWhileUntilLoopStatement(bool isTopTest, bool isWhile, Lazy condition, LoopKind loopKind, Lazy body, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + base(isTopTest, isWhile, loopKind, isInvalid, syntax, type, constantValue) { - IsTopTest = isTopTest; - IsWhile = isWhile; _lazyCondition = condition ?? throw new System.ArgumentNullException("condition"); _lazyBody = body ?? throw new System.ArgumentNullException("body"); } /// - /// True if the loop test executes at the top of the loop; false if the loop test executes at the bottom of the loop. - /// - public bool IsTopTest { get; } - /// - /// True if the loop is a while loop; false if the loop is an until loop. - /// - public bool IsWhile { get; } - /// /// Condition of the loop. /// public override IOperation Condition => _lazyCondition.Value; - /// /// Body of the loop. /// public override IOperation Body => _lazyBody.Value; - - public override void Accept(OperationVisitor visitor) - { - visitor.VisitWhileUntilLoopStatement(this); - } - public override TResult Accept(OperationVisitor visitor, TArgument argument) - { - return visitor.VisitWhileUntilLoopStatement(this, argument); - } } /// From 2e2bde42290a8e7944cd3dc11f10fd1e3246008b Mon Sep 17 00:00:00 2001 From: Heejae Chang Date: Mon, 26 Jun 2017 18:18:25 -0700 Subject: [PATCH 12/16] fixed wrong pattern --- .../Generated/Operations.xml.Generated.cs | 65 ++++--------------- 1 file changed, 14 insertions(+), 51 deletions(-) diff --git a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs index 9bc2a260826f5..1aea8219269b1 100644 --- a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs +++ b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs @@ -1638,9 +1638,10 @@ public LazyForEachLoopStatement(ILocalSymbol iterationVariable, Lazy /// internal abstract partial class BaseForLoopStatement : ForWhileUntilLoopStatement, IForLoopStatement { - public BaseForLoopStatement(LoopKind loopKind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + public BaseForLoopStatement(ImmutableArray locals, LoopKind loopKind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(loopKind, OperationKind.LoopStatement, isInvalid, syntax, type, constantValue) { + Locals = locals; } /// /// Statements to execute before entry to the loop. For C# these come from the first clause of the for statement. For VB these initialize the index variable of the For statement. @@ -1653,7 +1654,7 @@ public BaseForLoopStatement(LoopKind loopKind, bool isInvalid, SyntaxNode syntax /// /// Declarations local to the loop. /// - public abstract ImmutableArray Locals { get; } + public ImmutableArray Locals { get; } public override void Accept(OperationVisitor visitor) { @@ -1671,11 +1672,10 @@ public override TResult Accept(OperationVisitor before, ImmutableArray atLoopBottom, ImmutableArray locals, IOperation condition, LoopKind loopKind, IOperation body, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(loopKind, isInvalid, syntax, type, constantValue) + base(locals, loopKind, isInvalid, syntax, type, constantValue) { Before = before; AtLoopBottom = atLoopBottom; - Locals = locals; Condition = condition; Body = body; } @@ -1688,10 +1688,6 @@ public ForLoopStatement(ImmutableArray before, ImmutableArray public override ImmutableArray AtLoopBottom { get; } /// - /// Declarations local to the loop. - /// - public override ImmutableArray Locals { get; } - /// /// Condition of the loop. /// public override IOperation Condition { get; } @@ -1712,11 +1708,10 @@ internal sealed partial class LazyForLoopStatement : BaseForLoopStatement, IForL private readonly Lazy _lazyBody; public LazyForLoopStatement(Lazy> before, Lazy> atLoopBottom, ImmutableArray locals, Lazy condition, LoopKind loopKind, Lazy body, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(loopKind, isInvalid, syntax, type, constantValue) + base(locals, loopKind, isInvalid, syntax, type, constantValue) { _lazyBefore = before; _lazyAtLoopBottom = atLoopBottom; - Locals = locals; _lazyCondition = condition ?? throw new System.ArgumentNullException("condition"); _lazyBody = body ?? throw new System.ArgumentNullException("body"); } @@ -1730,10 +1725,6 @@ public LazyForLoopStatement(Lazy> before, Lazy public override ImmutableArray AtLoopBottom => _lazyAtLoopBottom.Value; - /// - /// Declarations local to the loop. - /// - public override ImmutableArray Locals { get; } /// /// Condition of the loop. /// @@ -1853,14 +1844,17 @@ public LazyIfStatement(Lazy condition, Lazy ifTrueStatem /// internal abstract partial class BaseIncrementExpression : Operation, IIncrementExpression { - public BaseIncrementExpression(bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : + public BaseIncrementExpression(UnaryOperationKind incrementOperationKind, bool usesOperatorMethod, IMethodSymbol operatorMethod, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(OperationKind.IncrementExpression, isInvalid, syntax, type, constantValue) { + IncrementOperationKind = incrementOperationKind; + UsesOperatorMethod = usesOperatorMethod; + OperatorMethod = operatorMethod; } /// /// Kind of increment. /// - public abstract UnaryOperationKind IncrementOperationKind { get; } + public UnaryOperationKind IncrementOperationKind { get; } /// /// Target of the assignment. /// @@ -1868,11 +1862,11 @@ public BaseIncrementExpression(bool isInvalid, SyntaxNode syntax, ITypeSymbol ty /// /// True if and only if the operation is performed by an operator method. /// - public abstract bool UsesOperatorMethod { get; } + public bool UsesOperatorMethod { get; } /// /// Operation method used by the operation, null if the operation does not use an operator method. /// - public abstract IMethodSymbol OperatorMethod { get; } + public IMethodSymbol OperatorMethod { get; } public override void Accept(OperationVisitor visitor) { @@ -1890,30 +1884,14 @@ public override TResult Accept(OperationVisitor constantValue) : - base(isInvalid, syntax, type, constantValue) + base(incrementOperationKind, usesOperatorMethod, operatorMethod, isInvalid, syntax, type, constantValue) { - IncrementOperationKind = incrementOperationKind; Target = target; - UsesOperatorMethod = usesOperatorMethod; - OperatorMethod = operatorMethod; } - - /// - /// Kind of increment. - /// - public override UnaryOperationKind IncrementOperationKind { get; } /// /// Target of the assignment. /// public override IOperation Target { get; } - /// - /// True if and only if the operation is performed by an operator method. - /// - public override bool UsesOperatorMethod { get; } - /// - /// Operation method used by the operation, null if the operation does not use an operator method. - /// - public override IMethodSymbol OperatorMethod { get; } } /// @@ -1924,29 +1902,14 @@ internal sealed partial class LazyIncrementExpression : BaseIncrementExpression, private readonly Lazy _lazyTarget; public LazyIncrementExpression(UnaryOperationKind incrementOperationKind, Lazy target, bool usesOperatorMethod, IMethodSymbol operatorMethod, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(isInvalid, syntax, type, constantValue) + base(incrementOperationKind, usesOperatorMethod, operatorMethod, isInvalid, syntax, type, constantValue) { - IncrementOperationKind = incrementOperationKind; _lazyTarget = target ?? throw new System.ArgumentNullException("target"); - UsesOperatorMethod = usesOperatorMethod; - OperatorMethod = operatorMethod; } /// - /// Kind of increment. - /// - public override UnaryOperationKind IncrementOperationKind { get; } - /// /// Target of the assignment. /// public override IOperation Target => _lazyTarget.Value; - /// - /// True if and only if the operation is performed by an operator method. - /// - public override bool UsesOperatorMethod { get; } - /// - /// Operation method used by the operation, null if the operation does not use an operator method. - /// - public override IMethodSymbol OperatorMethod { get; } } /// From d3a5cff9b6fe0b58e254cfb409bcc881d481bc06 Mon Sep 17 00:00:00 2001 From: Heejae Chang Date: Mon, 26 Jun 2017 18:20:56 -0700 Subject: [PATCH 13/16] more fix for consistancy --- .../Core/Portable/Generated/Operations.xml.Generated.cs | 2 +- src/Compilers/Core/Portable/Operations/OperationVisitor.cs | 2 +- src/Compilers/Core/Portable/PublicAPI.Unshipped.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs index 1aea8219269b1..8bbcb259de0a2 100644 --- a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs +++ b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs @@ -397,7 +397,7 @@ public override void Accept(OperationVisitor visitor) } public override TResult Accept(OperationVisitor visitor, TArgument argument) { - return visitor.VisitAssignmentExpression(this, argument); + return visitor.VisitSimpleAssignmentExpression(this, argument); } } diff --git a/src/Compilers/Core/Portable/Operations/OperationVisitor.cs b/src/Compilers/Core/Portable/Operations/OperationVisitor.cs index b0928be05d690..995826c707d78 100644 --- a/src/Compilers/Core/Portable/Operations/OperationVisitor.cs +++ b/src/Compilers/Core/Portable/Operations/OperationVisitor.cs @@ -760,7 +760,7 @@ public virtual TResult VisitArrayInitializer(IArrayInitializer operation, TArgum return DefaultVisit(operation, argument); } - public virtual TResult VisitAssignmentExpression(ISimpleAssignmentExpression operation, TArgument argument) + public virtual TResult VisitSimpleAssignmentExpression(ISimpleAssignmentExpression 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 b934609c6b6e4..2abb18e15657a 100644 --- a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt +++ b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt @@ -891,7 +891,6 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.Vi virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitArrayCreationExpression(Microsoft.CodeAnalysis.Semantics.IArrayCreationExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitArrayElementReferenceExpression(Microsoft.CodeAnalysis.Semantics.IArrayElementReferenceExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitArrayInitializer(Microsoft.CodeAnalysis.Semantics.IArrayInitializer operation, TArgument argument) -> TResult -virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitAssignmentExpression(Microsoft.CodeAnalysis.Semantics.ISimpleAssignmentExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitAwaitExpression(Microsoft.CodeAnalysis.Semantics.IAwaitExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitBinaryOperatorExpression(Microsoft.CodeAnalysis.Semantics.IBinaryOperatorExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitBlockStatement(Microsoft.CodeAnalysis.Semantics.IBlockStatement operation, TArgument argument) -> TResult @@ -948,6 +947,7 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.Vi virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitRangeCaseClause(Microsoft.CodeAnalysis.Semantics.IRangeCaseClause operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitRelationalCaseClause(Microsoft.CodeAnalysis.Semantics.IRelationalCaseClause operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitReturnStatement(Microsoft.CodeAnalysis.Semantics.IReturnStatement operation, TArgument argument) -> TResult +virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitSimpleAssignmentExpression(Microsoft.CodeAnalysis.Semantics.ISimpleAssignmentExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitSingleValueCaseClause(Microsoft.CodeAnalysis.Semantics.ISingleValueCaseClause operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitSizeOfExpression(Microsoft.CodeAnalysis.Semantics.ISizeOfExpression operation, TArgument argument) -> TResult virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitStopStatement(Microsoft.CodeAnalysis.Semantics.IStopStatement operation, TArgument argument) -> TResult From 03f3a6858495131122faa83ed879654f177ff246 Mon Sep 17 00:00:00 2001 From: Heejae Chang Date: Tue, 27 Jun 2017 14:15:08 -0700 Subject: [PATCH 14/16] made all tests pass --- .../IOperation/IOperationTests_IArgument.cs | 22 ++++++++--------- .../IOperationTests_IIfStatement.cs | 12 +++++----- ...IOperationTests_ILocalFunctionStatement.cs | 14 ++++------- ...perationTests_IObjectCreationExpression.cs | 24 +++++++++---------- ...tionTests_IParameterReferenceExpression.cs | 12 +++++----- .../IOperationTests_InvalidStatement.cs | 2 +- .../Generated/Operations.xml.Generated.cs | 1 + .../Semantic/IOperation/IOperationTests.vb | 8 +++---- .../IOperationTests_IIfStatement.vb | 20 ++++++++-------- ...perationTests_IObjectCreationExpression.vb | 24 +++++++++---------- ...tionTests_IParameterReferenceExpression.vb | 14 +++++------ .../IOperationTests_InvalidStatement.vb | 16 ++++++------- .../Compilation/OperationTreeVerifier.cs | 17 ++++--------- .../CouldHaveMoreSpecificTypeAnalyzer.cs | 21 ++++++++++++++-- .../FieldCouldBeReadOnlyAnalyzer.cs | 14 +++++++++-- .../Diagnostics/LocalCouldBeConstAnalyzer.cs | 14 +++++++++-- 16 files changed, 131 insertions(+), 104 deletions(-) diff --git a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IArgument.cs b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IArgument.cs index ee4368b1b1bc8..a6200d52660b5 100644 --- a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IArgument.cs +++ b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IArgument.cs @@ -1079,7 +1079,7 @@ void M1() } "; string expectedOperationTree = @" -IIndexedPropertyReferenceExpression: System.Int32 P.this[System.Int32 index] { get; set; } (OperationKind.IndexedPropertyReferenceExpression, Type: System.Int32) (Syntax: 'this[10]') +IPropertyReferenceExpression: System.Int32 P.this[System.Int32 index] { get; set; } (OperationKind.PropertyReferenceExpression, Type: System.Int32) (Syntax: 'this[10]') Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Explicit) (OperationKind.InstanceReferenceExpression, Type: P) (Syntax: 'this') Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: index) (OperationKind.Argument) (Syntax: '10') ILiteralExpression (Text: 10) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 10) (Syntax: '10') @@ -1109,7 +1109,7 @@ void M1() } "; string expectedOperationTree = @" -IIndexedPropertyReferenceExpression: System.Int32 P.this[System.Int32 index] { get; set; } (OperationKind.IndexedPropertyReferenceExpression, Type: System.Int32) (Syntax: 'this[10]') +IPropertyReferenceExpression: System.Int32 P.this[System.Int32 index] { get; set; } (OperationKind.PropertyReferenceExpression, Type: System.Int32) (Syntax: 'this[10]') Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Explicit) (OperationKind.InstanceReferenceExpression, Type: P) (Syntax: 'this') Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: index) (OperationKind.Argument) (Syntax: '10') ILiteralExpression (Text: 10) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 10) (Syntax: '10') @@ -1139,7 +1139,7 @@ void M1() } "; string expectedOperationTree = @" -IIndexedPropertyReferenceExpression: System.Int32 P.this[[System.Int32 i = 1], [System.Int32 j = 2]] { get; set; } (OperationKind.IndexedPropertyReferenceExpression, Type: System.Int32) (Syntax: 'this[j:10]') +IPropertyReferenceExpression: System.Int32 P.this[[System.Int32 i = 1], [System.Int32 j = 2]] { get; set; } (OperationKind.PropertyReferenceExpression, Type: System.Int32) (Syntax: 'this[j:10]') Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Explicit) (OperationKind.InstanceReferenceExpression, Type: P) (Syntax: 'this') Arguments(2): IArgument (ArgumentKind.Explicit, Matching Parameter: j) (OperationKind.Argument) (Syntax: '10') ILiteralExpression (Text: 10) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 10) (Syntax: '10') @@ -1171,7 +1171,7 @@ void M1() } "; string expectedOperationTree = @" -IIndexedPropertyReferenceExpression: System.Int32 P.this[System.Int32 index] { set; } (OperationKind.IndexedPropertyReferenceExpression, Type: System.Int32, IsInvalid) (Syntax: 'this[10]') +IPropertyReferenceExpression: System.Int32 P.this[System.Int32 index] { set; } (OperationKind.PropertyReferenceExpression, Type: System.Int32, IsInvalid) (Syntax: 'this[10]') Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Explicit) (OperationKind.InstanceReferenceExpression, Type: P) (Syntax: 'this') Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: null) (OperationKind.Argument, IsInvalid) (Syntax: '10') ILiteralExpression (Text: 10) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 10) (Syntax: '10')"; @@ -1203,7 +1203,7 @@ void M1() } "; string expectedOperationTree = @" -IIndexedPropertyReferenceExpression: System.Int32 P.this[System.Int32 index] { get; } (OperationKind.IndexedPropertyReferenceExpression, Type: System.Int32, IsInvalid) (Syntax: 'this[10]') +IPropertyReferenceExpression: System.Int32 P.this[System.Int32 index] { get; } (OperationKind.PropertyReferenceExpression, Type: System.Int32, IsInvalid) (Syntax: 'this[10]') Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Explicit) (OperationKind.InstanceReferenceExpression, Type: P) (Syntax: 'this') Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: null) (OperationKind.Argument, IsInvalid) (Syntax: '10') ILiteralExpression (Text: 10) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 10) (Syntax: '10') @@ -1249,7 +1249,7 @@ static void Main() } "; string expectedOperationTree = @" -IIndexedPropertyReferenceExpression: System.Int32 Derived.this[[System.Int32 x = 8], [System.Int32 y = 9]] { set; } (OperationKind.IndexedPropertyReferenceExpression, Type: System.Int32) (Syntax: 'd[0]') +IPropertyReferenceExpression: System.Int32 Derived.this[[System.Int32 x = 8], [System.Int32 y = 9]] { set; } (OperationKind.PropertyReferenceExpression, Type: System.Int32) (Syntax: 'd[0]') Instance Receiver: ILocalReferenceExpression: d (OperationKind.LocalReferenceExpression, Type: Derived) (Syntax: 'd') Arguments(2): IArgument (ArgumentKind.Explicit, Matching Parameter: x) (OperationKind.Argument) (Syntax: '0') ILiteralExpression (Text: 0) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 0) (Syntax: '0') @@ -1284,7 +1284,7 @@ public void M() } "; string expectedOperationTree = @" -IIndexedPropertyReferenceExpression: System.Int32 P.this[System.Int32 x, params System.Int32[] y] { get; set; } (OperationKind.IndexedPropertyReferenceExpression, Type: System.Int32) (Syntax: 'this[0]') +IPropertyReferenceExpression: System.Int32 P.this[System.Int32 x, params System.Int32[] y] { get; set; } (OperationKind.PropertyReferenceExpression, Type: System.Int32) (Syntax: 'this[0]') Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Explicit) (OperationKind.InstanceReferenceExpression, Type: P) (Syntax: 'this') Arguments(2): IArgument (ArgumentKind.Explicit, Matching Parameter: x) (OperationKind.Argument) (Syntax: '0') ILiteralExpression (Text: 0) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 0) (Syntax: '0') @@ -1316,7 +1316,7 @@ public void M() } "; string expectedOperationTree = @" -IIndexedPropertyReferenceExpression: ref System.Int32 P.this[System.Int32 x] { get; } (OperationKind.IndexedPropertyReferenceExpression, Type: System.Int32) (Syntax: 'this[0]') +IPropertyReferenceExpression: ref System.Int32 P.this[System.Int32 x] { get; } (OperationKind.PropertyReferenceExpression, Type: System.Int32) (Syntax: 'this[0]') Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Explicit) (OperationKind.InstanceReferenceExpression, Type: P) (Syntax: 'this') Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: x) (OperationKind.Argument) (Syntax: '0') ILiteralExpression (Text: 0) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 0) (Syntax: '0') @@ -1421,7 +1421,7 @@ public static void Main(string[] args) } "; string expectedOperationTree = @" -IIndexedPropertyReferenceExpression: System.Int32 P.this[[System.Int32 i = 3], [System.Int32 j = 4]] { get; set; } (OperationKind.IndexedPropertyReferenceExpression, Type: System.Int32) (Syntax: 'p[10]') +IPropertyReferenceExpression: System.Int32 P.this[[System.Int32 i = 3], [System.Int32 j = 4]] { get; set; } (OperationKind.PropertyReferenceExpression, Type: System.Int32) (Syntax: 'p[10]') Instance Receiver: ILocalReferenceExpression: p (OperationKind.LocalReferenceExpression, Type: P) (Syntax: 'p') Arguments(2): IArgument (ArgumentKind.Explicit, Matching Parameter: i) (OperationKind.Argument) (Syntax: '10') ILiteralExpression (Text: 10) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 10) (Syntax: '10') @@ -1531,7 +1531,7 @@ public static void Main(string[] args) } "; string expectedOperationTree = @" -IIndexedPropertyReferenceExpression: System.Int32 P.this[[System.Int32 i = 3], [System.Int32 j = 4]] { get; set; } (OperationKind.IndexedPropertyReferenceExpression, Type: System.Int32) (Syntax: 'p[10]') +IPropertyReferenceExpression: System.Int32 P.this[[System.Int32 i = 3], [System.Int32 j = 4]] { get; set; } (OperationKind.PropertyReferenceExpression, Type: System.Int32) (Syntax: 'p[10]') Instance Receiver: ILocalReferenceExpression: p (OperationKind.LocalReferenceExpression, Type: P) (Syntax: 'p') Arguments(2): IArgument (ArgumentKind.Explicit, Matching Parameter: i) (OperationKind.Argument) (Syntax: '10') ILiteralExpression (Text: 10) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 10) (Syntax: '10') @@ -1643,7 +1643,7 @@ public static void Main(string[] args) } "; string expectedOperationTree = @" -IIndexedPropertyReferenceExpression: System.Int32 P.this[[System.Int32 i = 3], [System.Int32 j = 4]] { get; set; } (OperationKind.IndexedPropertyReferenceExpression, Type: System.Int32) (Syntax: 'p[10]') +IPropertyReferenceExpression: System.Int32 P.this[[System.Int32 i = 3], [System.Int32 j = 4]] { get; set; } (OperationKind.PropertyReferenceExpression, Type: System.Int32) (Syntax: 'p[10]') Instance Receiver: ILocalReferenceExpression: p (OperationKind.LocalReferenceExpression, Type: P) (Syntax: 'p') Arguments(2): IArgument (ArgumentKind.Explicit, Matching Parameter: i) (OperationKind.Argument) (Syntax: '10') ILiteralExpression (Text: 10) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 10) (Syntax: '10') diff --git a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IIfStatement.cs b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IIfStatement.cs index 44d2562682b1e..f18493ba0b09e 100644 --- a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IIfStatement.cs +++ b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IIfStatement.cs @@ -31,7 +31,7 @@ private void M() Condition: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Boolean, Constant: True) (Syntax: 'true') IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'condition = true;') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Boolean) (Syntax: 'condition = true') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Boolean) (Syntax: 'condition = true') Left: ILocalReferenceExpression: condition (OperationKind.LocalReferenceExpression, Type: System.Boolean) (Syntax: 'condition') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Boolean, Constant: True) (Syntax: 'true') "; @@ -69,12 +69,12 @@ private void M() Condition: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Boolean, Constant: True) (Syntax: 'true') IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'condition = true;') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Boolean) (Syntax: 'condition = true') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Boolean) (Syntax: 'condition = true') Left: ILocalReferenceExpression: condition (OperationKind.LocalReferenceExpression, Type: System.Boolean) (Syntax: 'condition') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Boolean, Constant: True) (Syntax: 'true') IfFalse: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'condition = false;') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Boolean) (Syntax: 'condition = false') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Boolean) (Syntax: 'condition = false') Left: ILocalReferenceExpression: condition (OperationKind.LocalReferenceExpression, Type: System.Boolean) (Syntax: 'condition') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Boolean, Constant: False) (Syntax: 'false') "; @@ -114,7 +114,7 @@ private void M() Right: ILiteralExpression (Text: 1) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: '1') IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'condition = true;') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Boolean) (Syntax: 'condition = true') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Boolean) (Syntax: 'condition = true') Left: ILocalReferenceExpression: condition (OperationKind.LocalReferenceExpression, Type: System.Boolean) (Syntax: 'condition') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Boolean, Constant: True) (Syntax: 'true') "; @@ -683,12 +683,12 @@ private void M() IInvalidExpression (OperationKind.InvalidExpression, Type: ?, IsInvalid) (Syntax: '') IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'a = 2;') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Int32) (Syntax: 'a = 2') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: 'a = 2') Left: ILocalReferenceExpression: a (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'a') Right: ILiteralExpression (Text: 2) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 2) (Syntax: '2') IfFalse: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'a = 3;') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Int32) (Syntax: 'a = 3') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: 'a = 3') Left: ILocalReferenceExpression: a (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'a') Right: ILiteralExpression (Text: 3) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 3) (Syntax: '3') "; diff --git a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_ILocalFunctionStatement.cs b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_ILocalFunctionStatement.cs index d3c1c8fc49ffb..f5fbc2dc3f855 100644 --- a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_ILocalFunctionStatement.cs +++ b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_ILocalFunctionStatement.cs @@ -29,9 +29,8 @@ public void M(int x) ILocalFunctionStatement (Local Function: System.Int32 Local(System.Int32 p1)) (OperationKind.LocalFunctionStatement) (Syntax: 'int Local(i ... }') IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }') IReturnStatement (OperationKind.ReturnStatement) (Syntax: 'return x++;') - IIncrementExpression (UnaryOperandKind.IntegerPostfixIncrement) (BinaryOperationKind.IntegerAdd) (OperationKind.IncrementExpression, Type: System.Int32) (Syntax: 'x++') + IIncrementExpression (UnaryOperandKind.IntegerPostfixIncrement) (OperationKind.IncrementExpression, Type: System.Int32) (Syntax: 'x++') Left: IParameterReferenceExpression: x (OperationKind.ParameterReferenceExpression, Type: System.Int32) (Syntax: 'x') - Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: 'x++') "; var expectedDiagnostics = DiagnosticDescription.None; @@ -55,9 +54,8 @@ public void M(int x) ILocalFunctionStatement (Local Function: System.Int32 Local(System.Int32 p1)) (OperationKind.LocalFunctionStatement) (Syntax: 'int Local(i ... p1) => x++;') IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '=> x++') IReturnStatement (OperationKind.ReturnStatement) (Syntax: 'x++') - IIncrementExpression (UnaryOperandKind.IntegerPostfixIncrement) (BinaryOperationKind.IntegerAdd) (OperationKind.IncrementExpression, Type: System.Int32) (Syntax: 'x++') + IIncrementExpression (UnaryOperandKind.IntegerPostfixIncrement) (OperationKind.IncrementExpression, Type: System.Int32) (Syntax: 'x++') Left: IParameterReferenceExpression: x (OperationKind.ParameterReferenceExpression, Type: System.Int32) (Syntax: 'x') - Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: 'x++') "; var expectedDiagnostics = DiagnosticDescription.None; @@ -81,9 +79,8 @@ public void M() ILocalFunctionStatement (Local Function: System.Int32 Local(System.Int32 x)) (OperationKind.LocalFunctionStatement) (Syntax: 'int Local(int x) => x++;') IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '=> x++') IReturnStatement (OperationKind.ReturnStatement) (Syntax: 'x++') - IIncrementExpression (UnaryOperandKind.IntegerPostfixIncrement) (BinaryOperationKind.IntegerAdd) (OperationKind.IncrementExpression, Type: System.Int32) (Syntax: 'x++') + IIncrementExpression (UnaryOperandKind.IntegerPostfixIncrement) (OperationKind.IncrementExpression, Type: System.Int32) (Syntax: 'x++') Left: IParameterReferenceExpression: x (OperationKind.ParameterReferenceExpression, Type: System.Int32) (Syntax: 'x') - Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: 'x++') "; var expectedDiagnostics = DiagnosticDescription.None; @@ -263,9 +260,8 @@ void M() ILocalFunctionStatement (Local Function: void Foo()) (OperationKind.LocalFunctionStatement) (Syntax: 'void Foo() => x++;') IBlockStatement (2 statements) (OperationKind.BlockStatement) (Syntax: '=> x++') IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'x++') - IIncrementExpression (UnaryOperandKind.IntegerPostfixIncrement) (BinaryOperationKind.IntegerAdd) (OperationKind.IncrementExpression, Type: System.Int32) (Syntax: 'x++') + IIncrementExpression (UnaryOperandKind.IntegerPostfixIncrement) (OperationKind.IncrementExpression, Type: System.Int32) (Syntax: 'x++') Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'x') - Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: 'x++') IReturnStatement (OperationKind.ReturnStatement) (Syntax: '=> x++') "; var expectedDiagnostics = new DiagnosticDescription[] { @@ -295,7 +291,7 @@ void M(int p) ILocalFunctionStatement (Local Function: void Foo(out System.Int32 y)) (OperationKind.LocalFunctionStatement) (Syntax: 'void Foo(ou ... ) => y = p;') IBlockStatement (2 statements) (OperationKind.BlockStatement) (Syntax: '=> y = p') IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'y = p') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Int32) (Syntax: 'y = p') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: 'y = p') Left: IParameterReferenceExpression: y (OperationKind.ParameterReferenceExpression, Type: System.Int32) (Syntax: 'y') Right: IParameterReferenceExpression: p (OperationKind.ParameterReferenceExpression, Type: System.Int32) (Syntax: 'p') IReturnStatement (OperationKind.ReturnStatement) (Syntax: '=> y = p') diff --git a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IObjectCreationExpression.cs b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IObjectCreationExpression.cs index 2a5b571057c7d..0c2882a0a495b 100644 --- a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IObjectCreationExpression.cs +++ b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IObjectCreationExpression.cs @@ -57,41 +57,41 @@ public void M1() IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'var x2 = ne ... ield = 2 };') Variables: Local_1: F x2 Initializer: IObjectCreationExpression (Constructor: F..ctor()) (OperationKind.ObjectCreationExpression, Type: F) (Syntax: 'new F() { Field = 2 }') - Initializers(1): IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Int32) (Syntax: 'Field = 2') + Initializers(1): ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: 'Field = 2') Left: IOperation: (OperationKind.None) (Syntax: 'Field') Right: ILiteralExpression (Text: 2) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 2) (Syntax: '2') IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'var x3 = ne ... ty1 = """" };') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'var x3 = ne ... ty1 = """" };') Variables: Local_1: F x3 Initializer: IObjectCreationExpression (Constructor: F..ctor()) (OperationKind.ObjectCreationExpression, Type: F) (Syntax: 'new F() { P ... rty1 = """" }') - Initializers(1): IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.String) (Syntax: 'Property1 = """"') + Initializers(1): ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.String) (Syntax: 'Property1 = """"') Left: IOperation: (OperationKind.None) (Syntax: 'Property1') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.String, Constant: """") (Syntax: '""""') IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'var x4 = ne ... ield = 2 };') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'var x4 = ne ... ield = 2 };') Variables: Local_1: F x4 Initializer: IObjectCreationExpression (Constructor: F..ctor()) (OperationKind.ObjectCreationExpression, Type: F) (Syntax: 'new F() { P ... Field = 2 }') - Initializers(2): IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.String) (Syntax: 'Property1 = """"') + Initializers(2): ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.String) (Syntax: 'Property1 = """"') Left: IOperation: (OperationKind.None) (Syntax: 'Property1') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.String, Constant: """") (Syntax: '""""') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Int32) (Syntax: 'Field = 2') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: 'Field = 2') Left: IOperation: (OperationKind.None) (Syntax: 'Field') Right: ILiteralExpression (Text: 2) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 2) (Syntax: '2') IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement) (Syntax: 'var x5 = ne ... = true } };') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'var x5 = ne ... = true } };') Variables: Local_1: F x5 Initializer: IObjectCreationExpression (Constructor: F..ctor()) (OperationKind.ObjectCreationExpression, Type: F) (Syntax: 'new F() { P ... = true } }') - Initializers(1): IAssignmentExpression (OperationKind.AssignmentExpression, Type: B) (Syntax: 'Property2 = ... ld = true }') + Initializers(1): ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: B) (Syntax: 'Property2 = ... ld = true }') Left: IOperation: (OperationKind.None) (Syntax: 'Property2') Right: IObjectCreationExpression (Constructor: B..ctor()) (OperationKind.ObjectCreationExpression, Type: B) (Syntax: 'new B { Field = true }') - Initializers(1): IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Boolean) (Syntax: 'Field = true') + Initializers(1): ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Boolean) (Syntax: 'Field = true') Left: IOperation: (OperationKind.None) (Syntax: 'Field') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Boolean, Constant: True) (Syntax: 'true') IVariableDeclarationStatement (1 declarations) (OperationKind.VariableDeclarationStatement, IsInvalid) (Syntax: 'var e1 = ne ... rty2 = 1 };') IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration, IsInvalid) (Syntax: 'var e1 = ne ... rty2 = 1 };') Variables: Local_1: F e1 Initializer: IObjectCreationExpression (Constructor: F..ctor()) (OperationKind.ObjectCreationExpression, Type: F, IsInvalid) (Syntax: 'new F() { P ... erty2 = 1 }') - Initializers(1): IAssignmentExpression (OperationKind.AssignmentExpression, Type: B, IsInvalid) (Syntax: 'Property2 = 1') + Initializers(1): ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: B, IsInvalid) (Syntax: 'Property2 = 1') Left: IOperation: (OperationKind.None) (Syntax: 'Property2') Right: IConversionExpression (ConversionKind.Invalid, Implicit) (OperationKind.ConversionExpression, Type: B, IsInvalid) (Syntax: '1') ILiteralExpression (Text: 1) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: '1') @@ -220,10 +220,10 @@ public void M(int x) "; string expectedOperationTree = @" IObjectCreationExpression (Constructor: Class..ctor()) (OperationKind.ObjectCreationExpression, Type: Class) (Syntax: 'new Class() ... }') - Initializers(4): IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Int32) (Syntax: 'X = x') + Initializers(4): ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: 'X = x') Left: IOperation: (OperationKind.None) (Syntax: 'X') Right: IParameterReferenceExpression: x (OperationKind.ParameterReferenceExpression, Type: System.Int32) (Syntax: 'x') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Collections.Generic.List) (Syntax: 'Y = { x, y, 3 }') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Collections.Generic.List) (Syntax: 'Y = { x, y, 3 }') Left: IOperation: (OperationKind.None) (Syntax: 'Y') Right: IOperation: (OperationKind.None) (Syntax: '{ x, y, 3 }') Children(3): IOperation: (OperationKind.None) (Syntax: 'x') @@ -232,16 +232,16 @@ public void M(int x) Children(1): ILocalReferenceExpression: y (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'y') IOperation: (OperationKind.None) (Syntax: '3') Children(1): ILiteralExpression (Text: 3) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 3) (Syntax: '3') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Collections.Generic.Dictionary) (Syntax: 'Z = { { x, y } }') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Collections.Generic.Dictionary) (Syntax: 'Z = { { x, y } }') Left: IOperation: (OperationKind.None) (Syntax: 'Z') Right: IOperation: (OperationKind.None) (Syntax: '{ { x, y } }') Children(1): IOperation: (OperationKind.None) (Syntax: '{ x, y }') Children(2): IParameterReferenceExpression: x (OperationKind.ParameterReferenceExpression, Type: System.Int32) (Syntax: 'x') ILocalReferenceExpression: y (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'y') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: Class) (Syntax: 'C = { X = field }') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: Class) (Syntax: 'C = { X = field }') Left: IOperation: (OperationKind.None) (Syntax: 'C') Right: IOperation: (OperationKind.None) (Syntax: '{ X = field }') - Children(1): IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Int32) (Syntax: 'X = field') + Children(1): ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: 'X = field') Left: IOperation: (OperationKind.None) (Syntax: 'X') Right: IFieldReferenceExpression: System.Int32 Class.field (OperationKind.FieldReferenceExpression, Type: System.Int32) (Syntax: 'field') Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Implicit) (OperationKind.InstanceReferenceExpression, Type: Class) (Syntax: 'field') diff --git a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IParameterReferenceExpression.cs b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IParameterReferenceExpression.cs index a3520bbf3c848..b185d0c10cb29 100644 --- a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IParameterReferenceExpression.cs +++ b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IParameterReferenceExpression.cs @@ -165,10 +165,10 @@ public void M(int x, int y, int z) "; string expectedOperationTree = @" IObjectCreationExpression (Constructor: Class..ctor()) (OperationKind.ObjectCreationExpression, Type: Class) (Syntax: 'new Class() ... { X = z } }') - Initializers(4): IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Int32) (Syntax: 'X = x') + Initializers(4): ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: 'X = x') Left: IOperation: (OperationKind.None) (Syntax: 'X') Right: IParameterReferenceExpression: x (OperationKind.ParameterReferenceExpression, Type: System.Int32) (Syntax: 'x') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Collections.Generic.List) (Syntax: 'Y = { x, y, 3 }') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Collections.Generic.List) (Syntax: 'Y = { x, y, 3 }') Left: IOperation: (OperationKind.None) (Syntax: 'Y') Right: IOperation: (OperationKind.None) (Syntax: '{ x, y, 3 }') Children(3): IOperation: (OperationKind.None) (Syntax: 'x') @@ -177,16 +177,16 @@ public void M(int x, int y, int z) Children(1): IParameterReferenceExpression: y (OperationKind.ParameterReferenceExpression, Type: System.Int32) (Syntax: 'y') IOperation: (OperationKind.None) (Syntax: '3') Children(1): ILiteralExpression (Text: 3) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 3) (Syntax: '3') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Collections.Generic.Dictionary) (Syntax: 'Z = { { x, y } }') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Collections.Generic.Dictionary) (Syntax: 'Z = { { x, y } }') Left: IOperation: (OperationKind.None) (Syntax: 'Z') Right: IOperation: (OperationKind.None) (Syntax: '{ { x, y } }') Children(1): IOperation: (OperationKind.None) (Syntax: '{ x, y }') Children(2): IParameterReferenceExpression: x (OperationKind.ParameterReferenceExpression, Type: System.Int32) (Syntax: 'x') IParameterReferenceExpression: y (OperationKind.ParameterReferenceExpression, Type: System.Int32) (Syntax: 'y') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: Class) (Syntax: 'C = { X = z }') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: Class) (Syntax: 'C = { X = z }') Left: IOperation: (OperationKind.None) (Syntax: 'C') Right: IOperation: (OperationKind.None) (Syntax: '{ X = z }') - Children(1): IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Int32) (Syntax: 'X = z') + Children(1): ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: 'X = z') Left: IOperation: (OperationKind.None) (Syntax: 'X') Right: IParameterReferenceExpression: z (OperationKind.ParameterReferenceExpression, Type: System.Int32) (Syntax: 'z') "; @@ -303,7 +303,7 @@ public void M(int x, int y) "; string expectedOperationTree = @" IOperation: (OperationKind.None) (Syntax: '{ X = { { x, y } } }') - Children(1): IAssignmentExpression (OperationKind.AssignmentExpression, Type: dynamic) (Syntax: 'X = { { x, y } }') + Children(1): ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: dynamic) (Syntax: 'X = { { x, y } }') Left: IOperation: (OperationKind.None) (Syntax: 'X') Right: IOperation: (OperationKind.None) (Syntax: '{ { x, y } }') Children(1): IOperation: (OperationKind.None) (Syntax: '{ x, y }') diff --git a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_InvalidStatement.cs b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_InvalidStatement.cs index 07dc1aa3a619d..e339bf0ecc306 100644 --- a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_InvalidStatement.cs +++ b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_InvalidStatement.cs @@ -142,7 +142,7 @@ static void Main(string[] args) string expectedOperationTree = @" IIfStatement (OperationKind.IfStatement, IsInvalid) (Syntax: 'if (x = nul ... }') Condition: IConversionExpression (ConversionKind.Invalid, Implicit) (OperationKind.ConversionExpression, Type: System.Boolean, IsInvalid) (Syntax: 'x = null') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: Program) (Syntax: 'x = null') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: Program) (Syntax: 'x = null') Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: Program) (Syntax: 'x') Right: IConversionExpression (ConversionKind.Cast, Implicit) (OperationKind.ConversionExpression, Type: Program, Constant: null) (Syntax: 'null') ILiteralExpression (Text: null) (OperationKind.LiteralExpression, Type: null, Constant: null) (Syntax: 'null') diff --git a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs index 8bbcb259de0a2..4eebc639e74db 100644 --- a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs +++ b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs @@ -3003,6 +3003,7 @@ internal abstract partial class BaseParameterInitializer : SymbolInitializer, IP public BaseParameterInitializer(IParameterSymbol parameter, OperationKind kind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(kind, isInvalid, syntax, type, constantValue) { + Parameter = parameter; } /// /// Initialized parameter. diff --git a/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests.vb b/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests.vb index fa682f04356bb..4e480fff7d831 100644 --- a/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests.vb +++ b/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests.vb @@ -73,7 +73,7 @@ End Module comp.VerifyOperationTree(nodes(0), expectedOperationTree:=" IExpressionStatement (OperationKind.ExpressionStatement, IsInvalid) (Syntax: 'x = x + 10') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: B2, IsInvalid) (Syntax: 'x = x + 10') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: B2, IsInvalid) (Syntax: 'x = x + 10') Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: B2) (Syntax: 'x') Right: IBinaryOperatorExpression (BinaryOperationKind.OperatorMethodAdd) (OperationKind.BinaryOperatorExpression, Type: B2, IsInvalid) (Syntax: 'x + 10') Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: B2) (Syntax: 'x') @@ -103,7 +103,7 @@ IExpressionStatement (OperationKind.ExpressionStatement, IsInvalid) (Syntax: 'x comp.VerifyOperationTree(nodes(1), expectedOperationTree:=" IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'x = x + y') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: B2) (Syntax: 'x = x + y') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: B2) (Syntax: 'x = x + y') Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: B2) (Syntax: 'x') Right: IBinaryOperatorExpression (BinaryOperationKind.OperatorMethodAdd) (OperatorMethod: Function B2.op_Addition(x As B2, y As B2) As B2) (OperationKind.BinaryOperatorExpression, Type: B2) (Syntax: 'x + y') Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: B2) (Syntax: 'x') @@ -129,7 +129,7 @@ IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'x = x + y') comp.VerifyOperationTree(nodes(2), expectedOperationTree:=" IExpressionStatement (OperationKind.ExpressionStatement, IsInvalid) (Syntax: 'x = -x') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: B2, IsInvalid) (Syntax: 'x = -x') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: B2, IsInvalid) (Syntax: 'x = -x') Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: B2) (Syntax: 'x') Right: IUnaryOperatorExpression (UnaryOperationKind.OperatorMethodMinus) (OperationKind.UnaryOperatorExpression, Type: B2, IsInvalid) (Syntax: '-x') ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: B2) (Syntax: 'x') @@ -264,7 +264,7 @@ IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'For i = Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: ILiteralExpression (Text: 10) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 10) (Syntax: '10') Before: IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: '0') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Int32) (Syntax: '0') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: '0') Left: ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i') Right: ILiteralExpression (Text: 0) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 0) (Syntax: '0') AtLoopBottom: IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'For i = 0 T ... Next') diff --git a/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IIfStatement.vb b/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IIfStatement.vb index 1816ebf7fde92..7f2fe16cf0829 100644 --- a/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IIfStatement.vb +++ b/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IIfStatement.vb @@ -26,7 +26,7 @@ IIfStatement (OperationKind.IfStatement) (Syntax: 'If count > ... lue = count') Right: ILiteralExpression (Text: 0) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 0) (Syntax: '0') IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: 'If count > ... lue = count') IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'returnValue = count') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Int32) (Syntax: 'returnValue = count') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: 'returnValue = count') Left: ILocalReferenceExpression: returnValue (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'returnValue') Right: ILocalReferenceExpression: count (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'count') ]]>.Value @@ -57,7 +57,7 @@ IIfStatement (OperationKind.IfStatement) (Syntax: 'If count > ... End If') Right: ILiteralExpression (Text: 0) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 0) (Syntax: '0') IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: 'If count > ... End If') IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'returnValue = count') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Int32) (Syntax: 'returnValue = count') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: 'returnValue = count') Left: ILocalReferenceExpression: returnValue (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'returnValue') Right: ILocalReferenceExpression: count (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'count') ]]>.Value @@ -85,14 +85,14 @@ IIfStatement (OperationKind.IfStatement) (Syntax: 'If count > ... ata - count') Right: ILiteralExpression (Text: 10) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 10) (Syntax: '10') IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: 'If count > ... ata - count') IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'data = data + count') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Int32) (Syntax: 'data = data + count') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: 'data = data + count') Left: ILocalReferenceExpression: data (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'data') Right: IBinaryOperatorExpression (BinaryOperationKind.IntegerAdd) (OperationKind.BinaryOperatorExpression, Type: System.Int32) (Syntax: 'data + count') Left: ILocalReferenceExpression: data (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'data') Right: ILocalReferenceExpression: count (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'count') IfFalse: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: 'Else data = data - count') IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'data = data - count') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Int32) (Syntax: 'data = data - count') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: 'data = data - count') Left: ILocalReferenceExpression: data (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'data') Right: IBinaryOperatorExpression (BinaryOperationKind.IntegerSubtract) (OperationKind.BinaryOperatorExpression, Type: System.Int32) (Syntax: 'data - count') Left: ILocalReferenceExpression: data (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'data') @@ -128,7 +128,7 @@ IIfStatement (OperationKind.IfStatement) (Syntax: 'If m > 10 T ... rnValue = n') Right: ILiteralExpression (Text: 20) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 20) (Syntax: '20') IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: 'If n > 20 T ... rnValue = n') IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'returnValue = n') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Int32) (Syntax: 'returnValue = n') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: 'returnValue = n') Left: ILocalReferenceExpression: returnValue (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'returnValue') Right: ILocalReferenceExpression: n (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'n') ]]>.Value @@ -157,7 +157,7 @@ IIfStatement (OperationKind.IfStatement) (Syntax: 'If 1 = 1 Th ... End If') Right: ILiteralExpression (Text: 1) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: '1') IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: 'If 1 = 1 Th ... End If') IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'condition = True') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Boolean) (Syntax: 'condition = True') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Boolean) (Syntax: 'condition = True') Left: ILocalReferenceExpression: condition (OperationKind.LocalReferenceExpression, Type: System.Boolean) (Syntax: 'condition') Right: ILiteralExpression (Text: True) (OperationKind.LiteralExpression, Type: System.Boolean, Constant: True) (Syntax: 'True') ]]>.Value @@ -184,7 +184,7 @@ IIfStatement (OperationKind.IfStatement) (Syntax: 'If False Th ... End If') Condition: ILiteralExpression (Text: False) (OperationKind.LiteralExpression, Type: System.Boolean, Constant: False) (Syntax: 'False') IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: 'If False Th ... End If') IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'condition = False') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Boolean) (Syntax: 'condition = False') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Boolean) (Syntax: 'condition = False') Left: ILocalReferenceExpression: condition (OperationKind.LocalReferenceExpression, Type: System.Boolean) (Syntax: 'condition') Right: ILiteralExpression (Text: False) (OperationKind.LiteralExpression, Type: System.Boolean, Constant: False) (Syntax: 'False') ]]>.Value @@ -218,7 +218,7 @@ IIfStatement (OperationKind.IfStatement) (Syntax: 'If (m > 10 ... rnValue = n') Right: ILiteralExpression (Text: 20) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 20) (Syntax: '20') IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: 'If (m > 10 ... rnValue = n') IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'returnValue = n') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Int32) (Syntax: 'returnValue = n') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: 'returnValue = n') Left: ILocalReferenceExpression: returnValue (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'returnValue') Right: ILocalReferenceExpression: n (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'n') ]]>.Value @@ -250,12 +250,12 @@ IIfStatement (OperationKind.IfStatement) (Syntax: 'If count > ... End If') Right: ILiteralExpression (Text: 0) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 0) (Syntax: '0') IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: 'If count > ... End If') IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'returnValue = count') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Int32) (Syntax: 'returnValue = count') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: 'returnValue = count') Left: ILocalReferenceExpression: returnValue (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'returnValue') Right: ILocalReferenceExpression: count (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'count') IfFalse: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: 'Else ... nValue = -1') IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'returnValue = -1') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Int32) (Syntax: 'returnValue = -1') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: 'returnValue = -1') Left: ILocalReferenceExpression: returnValue (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'returnValue') Right: IUnaryOperatorExpression (UnaryOperationKind.IntegerMinus) (OperationKind.UnaryOperatorExpression, Type: System.Int32, Constant: -1) (Syntax: '-1') ILiteralExpression (Text: 1) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: '1') diff --git a/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IObjectCreationExpression.vb b/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IObjectCreationExpression.vb index d229cb04dba02..0901be40558d1 100644 --- a/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IObjectCreationExpression.vb +++ b/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IObjectCreationExpression.vb @@ -51,7 +51,7 @@ IBlockStatement (9 statements, 7 locals) (OperationKind.BlockStatement, IsInvali IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'x2') Variables: Local_1: x2 As F Initializer: IObjectCreationExpression (Constructor: Sub F..ctor()) (OperationKind.ObjectCreationExpression, Type: F) (Syntax: 'New F() Wit ... .Field = 2}') - Initializers(1): IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Int32) (Syntax: '.Field = 2') + Initializers(1): ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: '.Field = 2') Left: IFieldReferenceExpression: F.Field As System.Int32 (OperationKind.FieldReferenceExpression, Type: System.Int32) (Syntax: 'Field') Instance Receiver: IOperation: (OperationKind.None) (Syntax: 'New F() Wit ... .Field = 2}') Right: ILiteralExpression (Text: 2) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 2) (Syntax: '2') @@ -59,7 +59,7 @@ IBlockStatement (9 statements, 7 locals) (OperationKind.BlockStatement, IsInvali IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'x3') Variables: Local_1: x3 As F Initializer: IObjectCreationExpression (Constructor: Sub F..ctor()) (OperationKind.ObjectCreationExpression, Type: F) (Syntax: 'New F() Wit ... erty1 = ""}') - Initializers(1): IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Void) (Syntax: '.Property1 = ""') + Initializers(1): ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Void) (Syntax: '.Property1 = ""') Left: IPropertyReferenceExpression: Property F.Property1 As System.String (OperationKind.PropertyReferenceExpression, Type: System.String) (Syntax: 'Property1') Instance Receiver: IOperation: (OperationKind.None) (Syntax: 'New F() Wit ... erty1 = ""}') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.String, Constant: "") (Syntax: '""') @@ -67,11 +67,11 @@ IBlockStatement (9 statements, 7 locals) (OperationKind.BlockStatement, IsInvali IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'x4') Variables: Local_1: x4 As F Initializer: IObjectCreationExpression (Constructor: Sub F..ctor()) (OperationKind.ObjectCreationExpression, Type: F) (Syntax: 'New F() Wit ... .Field = 2}') - Initializers(2): IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Void) (Syntax: '.Property1 = ""') + Initializers(2): ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Void) (Syntax: '.Property1 = ""') Left: IPropertyReferenceExpression: Property F.Property1 As System.String (OperationKind.PropertyReferenceExpression, Type: System.String) (Syntax: 'Property1') Instance Receiver: IOperation: (OperationKind.None) (Syntax: 'New F() Wit ... .Field = 2}') Right: ILiteralExpression (OperationKind.LiteralExpression, Type: System.String, Constant: "") (Syntax: '""') - IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Int32) (Syntax: '.Field = 2') + ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Int32) (Syntax: '.Field = 2') Left: IFieldReferenceExpression: F.Field As System.Int32 (OperationKind.FieldReferenceExpression, Type: System.Int32) (Syntax: 'Field') Instance Receiver: IOperation: (OperationKind.None) (Syntax: 'New F() Wit ... .Field = 2}') Right: ILiteralExpression (Text: 2) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 2) (Syntax: '2') @@ -79,11 +79,11 @@ IBlockStatement (9 statements, 7 locals) (OperationKind.BlockStatement, IsInvali IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration) (Syntax: 'x5') Variables: Local_1: x5 As F Initializer: IObjectCreationExpression (Constructor: Sub F..ctor()) (OperationKind.ObjectCreationExpression, Type: F) (Syntax: 'New F() Wit ... ld = True}}') - Initializers(1): IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Void) (Syntax: '.Property2 ... eld = True}') + Initializers(1): ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Void) (Syntax: '.Property2 ... eld = True}') Left: IPropertyReferenceExpression: Property F.Property2 As B (OperationKind.PropertyReferenceExpression, Type: B) (Syntax: 'Property2') Instance Receiver: IOperation: (OperationKind.None) (Syntax: 'New F() Wit ... ld = True}}') Right: IObjectCreationExpression (Constructor: Sub B..ctor()) (OperationKind.ObjectCreationExpression, Type: B) (Syntax: 'New B() Wit ... eld = True}') - Initializers(1): IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Boolean) (Syntax: '.Field = True') + Initializers(1): ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Boolean) (Syntax: '.Field = True') Left: IFieldReferenceExpression: B.Field As System.Boolean (OperationKind.FieldReferenceExpression, Type: System.Boolean) (Syntax: 'Field') Instance Receiver: IOperation: (OperationKind.None) (Syntax: 'New B() Wit ... eld = True}') Right: ILiteralExpression (Text: True) (OperationKind.LiteralExpression, Type: System.Boolean, Constant: True) (Syntax: 'True') @@ -91,7 +91,7 @@ IBlockStatement (9 statements, 7 locals) (OperationKind.BlockStatement, IsInvali IVariableDeclaration (1 variables) (OperationKind.VariableDeclaration, IsInvalid) (Syntax: 'e1') Variables: Local_1: e1 As F Initializer: IObjectCreationExpression (Constructor: Sub F..ctor()) (OperationKind.ObjectCreationExpression, Type: F, IsInvalid) (Syntax: 'New F() Wit ... perty2 = 1}') - Initializers(1): IAssignmentExpression (OperationKind.AssignmentExpression, Type: System.Void, IsInvalid) (Syntax: '.Property2 = 1') + Initializers(1): ISimpleAssignmentExpression (OperationKind.SimpleAssignmentExpression, Type: System.Void, IsInvalid) (Syntax: '.Property2 = 1') Left: IPropertyReferenceExpression: Property F.Property2 As B (OperationKind.PropertyReferenceExpression, Type: B) (Syntax: 'Property2') Instance Receiver: IOperation: (OperationKind.None) (Syntax: 'New F() Wit ... perty2 = 1}') Right: IConversionExpression (ConversionKind.Basic, Implicit) (OperationKind.ConversionExpression, Type: B, IsInvalid) (Syntax: '1') @@ -223,11 +223,11 @@ End Class]]>.Value Dim expectedOperationTree = .Value Dim expectedOperationTree = .Value Dim expectedOperationTree = .Value Dim expectedOperationTree = 0) { - // keep existing logging behavior - LogString("IIndexedPropertyReferenceExpression"); - LogString($": {operation.Property.ToTestDisplayString()}"); - - VisitMemberReferenceExpressionCommon(operation); VisitArguments(operation); } - else - { - LogString(nameof(IPropertyReferenceExpression)); - LogString($": {operation.Property.ToTestDisplayString()}"); - - VisitMemberReferenceExpressionCommon(operation); - } } public override void VisitEventReferenceExpression(IEventReferenceExpression operation) diff --git a/src/Test/Utilities/Portable/Diagnostics/CouldHaveMoreSpecificTypeAnalyzer.cs b/src/Test/Utilities/Portable/Diagnostics/CouldHaveMoreSpecificTypeAnalyzer.cs index a657eb8767816..fb0ef85f8c5a7 100644 --- a/src/Test/Utilities/Portable/Diagnostics/CouldHaveMoreSpecificTypeAnalyzer.cs +++ b/src/Test/Utilities/Portable/Diagnostics/CouldHaveMoreSpecificTypeAnalyzer.cs @@ -55,8 +55,25 @@ public sealed override void Initialize(AnalysisContext context) operationBlockContext.RegisterOperationAction( (operationContext) => { - IAssignmentExpression assignment = (IAssignmentExpression)operationContext.Operation; - AssignTo(assignment.Target, localsSourceTypes, fieldsSourceTypes, assignment.Value); + if (operationContext.Operation is IAssignmentExpression assignment) + { + AssignTo(assignment.Target, localsSourceTypes, fieldsSourceTypes, assignment.Value); + } + else if (operationContext.Operation is IIncrementExpression increment) + { + string text = increment.Syntax.ToString(); + bool isInvalid = false; + SyntaxNode syntax = increment.Syntax; + ITypeSymbol type = increment.Type; + Optional constantValue = new Optional(1); + var value = new LiteralExpression(text, isInvalid, syntax, type, constantValue); + + AssignTo(increment.Target, localsSourceTypes, fieldsSourceTypes, value); + } + else + { + throw TestExceptionUtilities.UnexpectedValue(operationContext.Operation); + } }, OperationKind.SimpleAssignmentExpression, OperationKind.CompoundAssignmentExpression, diff --git a/src/Test/Utilities/Portable/Diagnostics/FieldCouldBeReadOnlyAnalyzer.cs b/src/Test/Utilities/Portable/Diagnostics/FieldCouldBeReadOnlyAnalyzer.cs index 1bcc9973736e3..77cb206f32036 100644 --- a/src/Test/Utilities/Portable/Diagnostics/FieldCouldBeReadOnlyAnalyzer.cs +++ b/src/Test/Utilities/Portable/Diagnostics/FieldCouldBeReadOnlyAnalyzer.cs @@ -48,8 +48,18 @@ public sealed override void Initialize(AnalysisContext context) operationBlockContext.RegisterOperationAction( (operationContext) => { - IAssignmentExpression assignment = (IAssignmentExpression)operationContext.Operation; - AssignTo(assignment.Target, inConstructor, staticConstructorType, assignedToFields, mightBecomeReadOnlyFields); + if (operationContext.Operation is IAssignmentExpression assignment) + { + AssignTo(assignment.Target, inConstructor, staticConstructorType, assignedToFields, mightBecomeReadOnlyFields); + } + else if (operationContext.Operation is IIncrementExpression increment) + { + AssignTo(increment.Target, inConstructor, staticConstructorType, assignedToFields, mightBecomeReadOnlyFields); + } + else + { + throw TestExceptionUtilities.UnexpectedValue(operationContext.Operation); + } }, OperationKind.SimpleAssignmentExpression, OperationKind.CompoundAssignmentExpression, diff --git a/src/Test/Utilities/Portable/Diagnostics/LocalCouldBeConstAnalyzer.cs b/src/Test/Utilities/Portable/Diagnostics/LocalCouldBeConstAnalyzer.cs index f9743eef1c1eb..ed6867460fe41 100644 --- a/src/Test/Utilities/Portable/Diagnostics/LocalCouldBeConstAnalyzer.cs +++ b/src/Test/Utilities/Portable/Diagnostics/LocalCouldBeConstAnalyzer.cs @@ -42,8 +42,18 @@ public sealed override void Initialize(AnalysisContext context) operationBlockContext.RegisterOperationAction( (operationContext) => { - IAssignmentExpression assignment = (IAssignmentExpression)operationContext.Operation; - AssignTo(assignment.Target, assignedToLocals, mightBecomeConstLocals); + if (operationContext.Operation is IAssignmentExpression assignment) + { + AssignTo(assignment.Target, assignedToLocals, mightBecomeConstLocals); + } + else if (operationContext.Operation is IIncrementExpression increment) + { + AssignTo(increment.Target, assignedToLocals, mightBecomeConstLocals); + } + else + { + throw TestExceptionUtilities.UnexpectedValue(operationContext.Operation); + } }, OperationKind.SimpleAssignmentExpression, OperationKind.CompoundAssignmentExpression, From 5f680d6aad3a949780289d2f3e99a1a36e666503 Mon Sep 17 00:00:00 2001 From: Heejae Chang Date: Thu, 29 Jun 2017 20:20:32 -0700 Subject: [PATCH 15/16] addressed PR feedback --- .../Generated/Operations.xml.Generated.cs | 160 +++++------ .../Core/Portable/PublicAPI.Unshipped.txt | 4 - .../Diagnostics/OperationTestAnalyzer.cs | 264 +++++++++--------- 3 files changed, 217 insertions(+), 211 deletions(-) diff --git a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs index 4eebc639e74db..46e952e3a642b 100644 --- a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs +++ b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs @@ -52,7 +52,7 @@ internal sealed partial class LazyAddressOfExpression : BaseAddressOfExpression, public LazyAddressOfExpression(Lazy reference, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(isInvalid, syntax, type, constantValue) { - _lazyReference = reference ?? throw new System.ArgumentNullException("reference"); + _lazyReference = reference ?? throw new System.ArgumentNullException(nameof(reference)); } /// /// Addressed reference. @@ -138,9 +138,9 @@ internal sealed partial class LazyArgument : BaseArgument, IArgument public LazyArgument(ArgumentKind argumentKind, IParameterSymbol parameter, Lazy value, Lazy inConversion, Lazy outConversion, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(argumentKind, parameter, isInvalid, syntax, type, constantValue) { - _lazyValue = value ?? throw new System.ArgumentNullException("value"); - _lazyInConversion = inConversion ?? throw new System.ArgumentNullException("inConversion"); - _lazyOutConversion = outConversion ?? throw new System.ArgumentNullException("outConversion"); + _lazyValue = value ?? throw new System.ArgumentNullException(nameof(value)); + _lazyInConversion = inConversion ?? throw new System.ArgumentNullException(nameof(inConversion)); + _lazyOutConversion = outConversion ?? throw new System.ArgumentNullException(nameof(outConversion)); } /// /// Value supplied for the argument. @@ -222,7 +222,7 @@ internal sealed partial class LazyArrayCreationExpression : BaseArrayCreationExp public LazyArrayCreationExpression(ITypeSymbol elementType, Lazy> dimensionSizes, Lazy initializer, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(elementType, isInvalid, syntax, type, constantValue) { _lazyDimensionSizes = dimensionSizes; - _lazyInitializer = initializer ?? throw new System.ArgumentNullException("initializer"); + _lazyInitializer = initializer ?? throw new System.ArgumentNullException(nameof(initializer)); } /// /// Sizes of the dimensions of the created array instance. @@ -293,7 +293,7 @@ internal sealed partial class LazyArrayElementReferenceExpression : BaseArrayEle public LazyArrayElementReferenceExpression(Lazy arrayReference, Lazy> indices, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(isInvalid, syntax, type, constantValue) { - _lazyArrayReference = arrayReference ?? throw new System.ArgumentNullException("arrayReference"); + _lazyArrayReference = arrayReference ?? throw new System.ArgumentNullException(nameof(arrayReference)); _lazyIndices = indices; } /// @@ -383,7 +383,7 @@ protected AssignmentExpression(OperationKind kind, bool isInvalid, SyntaxNode sy } /// - /// Represents an assignment expression. + /// Represents a simple assignment expression. /// internal abstract partial class BaseSimpleAssignmentExpression : AssignmentExpression, ISimpleAssignmentExpression { @@ -402,7 +402,7 @@ public override TResult Accept(OperationVisitor - /// Represents an assignment expression. + /// Represents a simple assignment expression. /// internal sealed partial class SimpleAssignmentExpression : BaseSimpleAssignmentExpression, ISimpleAssignmentExpression { @@ -433,8 +433,8 @@ internal sealed partial class LazySimpleAssignmentExpression : BaseSimpleAssignm public LazySimpleAssignmentExpression(Lazy target, Lazy value, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(isInvalid, syntax, type, constantValue) { - _lazyTarget = target ?? throw new System.ArgumentNullException("target"); - _lazyValue = value ?? throw new System.ArgumentNullException("value"); + _lazyTarget = target ?? throw new System.ArgumentNullException(nameof(target)); + _lazyValue = value ?? throw new System.ArgumentNullException(nameof(value)); } /// /// Target of the assignment. @@ -495,7 +495,7 @@ internal sealed partial class LazyAwaitExpression : BaseAwaitExpression, IAwaitE public LazyAwaitExpression(Lazy awaitedValue, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(isInvalid, syntax, type, constantValue) { - _lazyAwaitedValue = awaitedValue ?? throw new System.ArgumentNullException("awaitedValue"); + _lazyAwaitedValue = awaitedValue ?? throw new System.ArgumentNullException(nameof(awaitedValue)); } /// /// Value to be awaited. @@ -576,8 +576,8 @@ internal sealed partial class LazyBinaryOperatorExpression : BaseBinaryOperatorE public LazyBinaryOperatorExpression(BinaryOperationKind binaryOperationKind, Lazy leftOperand, Lazy rightOperand, bool usesOperatorMethod, IMethodSymbol operatorMethod, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(binaryOperationKind, usesOperatorMethod, operatorMethod, isInvalid, syntax, type, constantValue) { - _lazyLeftOperand = leftOperand ?? throw new System.ArgumentNullException("leftOperand"); - _lazyRightOperand = rightOperand ?? throw new System.ArgumentNullException("rightOperand"); + _lazyLeftOperand = leftOperand ?? throw new System.ArgumentNullException(nameof(leftOperand)); + _lazyRightOperand = rightOperand ?? throw new System.ArgumentNullException(nameof(rightOperand)); } /// /// Left operand. @@ -764,8 +764,8 @@ internal sealed partial class LazyCatchClause : BaseCatchClause, ICatchClause public LazyCatchClause(Lazy handler, ITypeSymbol caughtType, Lazy filter, ILocalSymbol exceptionLocal, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(caughtType, exceptionLocal, isInvalid, syntax, type, constantValue) { - _lazyHandler = handler ?? throw new System.ArgumentNullException("handler"); - _lazyFilter = filter ?? throw new System.ArgumentNullException("filter"); + _lazyHandler = handler ?? throw new System.ArgumentNullException(nameof(handler)); + _lazyFilter = filter ?? throw new System.ArgumentNullException(nameof(filter)); } /// /// Body of the exception handler. @@ -845,8 +845,8 @@ internal sealed partial class LazyCompoundAssignmentExpression : BaseCompoundAss public LazyCompoundAssignmentExpression(BinaryOperationKind binaryOperationKind, Lazy target, Lazy value, bool usesOperatorMethod, IMethodSymbol operatorMethod, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(binaryOperationKind, usesOperatorMethod, operatorMethod, isInvalid, syntax, type, constantValue) { - _lazyTarget = target ?? throw new System.ArgumentNullException("target"); - _lazyValue = value ?? throw new System.ArgumentNullException("value"); + _lazyTarget = target ?? throw new System.ArgumentNullException(nameof(target)); + _lazyValue = value ?? throw new System.ArgumentNullException(nameof(value)); } /// /// Target of the assignment. @@ -917,8 +917,8 @@ internal sealed partial class LazyConditionalAccessExpression : BaseConditionalA public LazyConditionalAccessExpression(Lazy conditionalValue, Lazy conditionalInstance, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(isInvalid, syntax, type, constantValue) { - _lazyConditionalValue = conditionalValue ?? throw new System.ArgumentNullException("conditionalValue"); - _lazyConditionalInstance = conditionalInstance ?? throw new System.ArgumentNullException("conditionalInstance"); + _lazyConditionalValue = conditionalValue ?? throw new System.ArgumentNullException(nameof(conditionalValue)); + _lazyConditionalInstance = conditionalInstance ?? throw new System.ArgumentNullException(nameof(conditionalInstance)); } /// /// Expression to be evaluated if the conditional instance is non null. @@ -1018,9 +1018,9 @@ internal sealed partial class LazyConditionalChoiceExpression : BaseConditionalC public LazyConditionalChoiceExpression(Lazy condition, Lazy ifTrueValue, Lazy ifFalseValue, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(isInvalid, syntax, type, constantValue) { - _lazyCondition = condition ?? throw new System.ArgumentNullException("condition"); - _lazyIfTrueValue = ifTrueValue ?? throw new System.ArgumentNullException("ifTrueValue"); - _lazyIfFalseValue = ifFalseValue ?? throw new System.ArgumentNullException("ifFalseValue"); + _lazyCondition = condition ?? throw new System.ArgumentNullException(nameof(condition)); + _lazyIfTrueValue = ifTrueValue ?? throw new System.ArgumentNullException(nameof(ifTrueValue)); + _lazyIfFalseValue = ifFalseValue ?? throw new System.ArgumentNullException(nameof(ifFalseValue)); } /// /// Condition to be tested. @@ -1106,7 +1106,7 @@ internal sealed partial class LazyConversionExpression : BaseConversionExpressio public LazyConversionExpression(Lazy operand, ConversionKind conversionKind, bool isExplicit, bool usesOperatorMethod, IMethodSymbol operatorMethod, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(conversionKind, isExplicit, usesOperatorMethod, operatorMethod, isInvalid, syntax, type, constantValue) { - _lazyOperand = operand ?? throw new System.ArgumentNullException("operand"); + _lazyOperand = operand ?? throw new System.ArgumentNullException(nameof(operand)); } /// /// Value to be converted. @@ -1245,8 +1245,8 @@ internal sealed partial class LazyEventAssignmentExpression : BaseEventAssignmen public LazyEventAssignmentExpression(IEventSymbol @event, Lazy eventInstance, Lazy handlerValue, bool adds, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(@event, adds, isInvalid, syntax, type, constantValue) { - _lazyEventInstance = eventInstance ?? throw new System.ArgumentNullException("eventInstance"); - _lazyHandlerValue = handlerValue ?? throw new System.ArgumentNullException("handlerValue"); + _lazyEventInstance = eventInstance ?? throw new System.ArgumentNullException(nameof(eventInstance)); + _lazyHandlerValue = handlerValue ?? throw new System.ArgumentNullException(nameof(handlerValue)); } /// @@ -1311,7 +1311,7 @@ internal sealed partial class LazyEventReferenceExpression : BaseEventReferenceE public LazyEventReferenceExpression(IEventSymbol @event, Lazy instance, ISymbol member, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(@event, member, isInvalid, syntax, type, constantValue) { - _lazyInstance = instance ?? throw new System.ArgumentNullException("instance"); + _lazyInstance = instance ?? throw new System.ArgumentNullException(nameof(instance)); } /// /// Instance of the type. Null if the reference is to a static/shared member. @@ -1367,7 +1367,7 @@ internal sealed partial class LazyExpressionStatement : BaseExpressionStatement, public LazyExpressionStatement(Lazy expression, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(isInvalid, syntax, type, constantValue) { - _lazyExpression = expression ?? throw new System.ArgumentNullException("expression"); + _lazyExpression = expression ?? throw new System.ArgumentNullException(nameof(expression)); } /// /// Expression of the statement. @@ -1423,7 +1423,7 @@ internal sealed partial class LazyFieldInitializer : BaseFieldInitializer, IFiel public LazyFieldInitializer(ImmutableArray initializedFields, Lazy value, OperationKind kind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(initializedFields, kind, isInvalid, syntax, type, constantValue) { - _lazyValue = value ?? throw new System.ArgumentNullException("value"); + _lazyValue = value ?? throw new System.ArgumentNullException(nameof(value)); } public override IOperation Value => _lazyValue.Value; } @@ -1479,7 +1479,7 @@ internal sealed partial class LazyFieldReferenceExpression : BaseFieldReferenceE public LazyFieldReferenceExpression(IFieldSymbol field, Lazy instance, ISymbol member, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(field, member, isInvalid, syntax, type, constantValue) { - _lazyInstance = instance ?? throw new System.ArgumentNullException("instance"); + _lazyInstance = instance ?? throw new System.ArgumentNullException(nameof(instance)); } /// /// Instance of the type. Null if the reference is to a static/shared member. @@ -1545,8 +1545,8 @@ internal sealed partial class LazyFixedStatement : BaseFixedStatement, IFixedSta public LazyFixedStatement(Lazy variables, Lazy body, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(isInvalid, syntax, type, constantValue) { - _lazyVariables = variables ?? throw new System.ArgumentNullException("variables"); - _lazyBody = body ?? throw new System.ArgumentNullException("body"); + _lazyVariables = variables ?? throw new System.ArgumentNullException(nameof(variables)); + _lazyBody = body ?? throw new System.ArgumentNullException(nameof(body)); } /// /// Variables to be fixed. @@ -1620,8 +1620,8 @@ internal sealed partial class LazyForEachLoopStatement : BaseForEachLoopStatemen public LazyForEachLoopStatement(ILocalSymbol iterationVariable, Lazy collection, LoopKind loopKind, Lazy body, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(iterationVariable, loopKind, isInvalid, syntax, type, constantValue) { - _lazyCollection = collection ?? throw new System.ArgumentNullException("collection"); - _lazyBody = body ?? throw new System.ArgumentNullException("body"); + _lazyCollection = collection ?? throw new System.ArgumentNullException(nameof(collection)); + _lazyBody = body ?? throw new System.ArgumentNullException(nameof(body)); } /// /// Collection value over which the loop iterates. @@ -1712,8 +1712,8 @@ public LazyForLoopStatement(Lazy> before, Lazy /// Statements to execute before entry to the loop. For C# these come from the first clause of the for statement. For VB these initialize the index variable of the For statement. @@ -1819,9 +1819,9 @@ internal sealed partial class LazyIfStatement : BaseIfStatement, IIfStatement public LazyIfStatement(Lazy condition, Lazy ifTrueStatement, Lazy ifFalseStatement, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(isInvalid, syntax, type, constantValue) { - _lazyCondition = condition ?? throw new System.ArgumentNullException("condition"); - _lazyIfTrueStatement = ifTrueStatement ?? throw new System.ArgumentNullException("ifTrueStatement"); - _lazyIfFalseStatement = ifFalseStatement ?? throw new System.ArgumentNullException("ifFalseStatement"); + _lazyCondition = condition ?? throw new System.ArgumentNullException(nameof(condition)); + _lazyIfTrueStatement = ifTrueStatement ?? throw new System.ArgumentNullException(nameof(ifTrueStatement)); + _lazyIfFalseStatement = ifFalseStatement ?? throw new System.ArgumentNullException(nameof(ifFalseStatement)); } /// /// Condition of the if statement. For C# there is naturally one clause per if, but for VB If statements with multiple clauses are rewritten to have only one. @@ -1904,7 +1904,7 @@ internal sealed partial class LazyIncrementExpression : BaseIncrementExpression, public LazyIncrementExpression(UnaryOperationKind incrementOperationKind, Lazy target, bool usesOperatorMethod, IMethodSymbol operatorMethod, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(incrementOperationKind, usesOperatorMethod, operatorMethod, isInvalid, syntax, type, constantValue) { - _lazyTarget = target ?? throw new System.ArgumentNullException("target"); + _lazyTarget = target ?? throw new System.ArgumentNullException(nameof(target)); } /// /// Target of the assignment. @@ -2327,7 +2327,7 @@ internal sealed partial class LazyInvocationExpression : BaseInvocationExpressio public LazyInvocationExpression(IMethodSymbol targetMethod, Lazy instance, bool isVirtual, Lazy> argumentsInEvaluationOrder, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(targetMethod, isVirtual, isInvalid, syntax, type, constantValue) { - _lazyInstance = instance ?? throw new System.ArgumentNullException("instance"); + _lazyInstance = instance ?? throw new System.ArgumentNullException(nameof(instance)); _lazyArgumentsInEvaluationOrder = argumentsInEvaluationOrder; } /// @@ -2398,7 +2398,7 @@ internal sealed partial class LazyIsTypeExpression : BaseIsTypeExpression, IIsTy public LazyIsTypeExpression(Lazy operand, ITypeSymbol isType, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(isType, isInvalid, syntax, type, constantValue) { - _lazyOperand = operand ?? throw new System.ArgumentNullException("operand"); + _lazyOperand = operand ?? throw new System.ArgumentNullException(nameof(operand)); } /// /// Value to test. @@ -2459,7 +2459,7 @@ internal sealed partial class LazyLabelStatement : BaseLabelStatement, ILabelSta public LazyLabelStatement(ILabelSymbol label, Lazy labeledStatement, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(label, isInvalid, syntax, type, constantValue) { - _lazyLabeledStatement = labeledStatement ?? throw new System.ArgumentNullException("labeledStatement"); + _lazyLabeledStatement = labeledStatement ?? throw new System.ArgumentNullException(nameof(labeledStatement)); } /// /// Statement that has been labeled. @@ -2520,7 +2520,7 @@ internal sealed partial class LazyLambdaExpression : BaseLambdaExpression, ILamb public LazyLambdaExpression(IMethodSymbol signature, Lazy body, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(signature, isInvalid, syntax, type, constantValue) { - _lazyBody = body ?? throw new System.ArgumentNullException("body"); + _lazyBody = body ?? throw new System.ArgumentNullException(nameof(body)); } /// /// Body of the lambda. @@ -2581,7 +2581,7 @@ internal sealed partial class LazyLateBoundMemberReferenceExpression : BaseLateB public LazyLateBoundMemberReferenceExpression(Lazy instance, string memberName, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(memberName, isInvalid, syntax, type, constantValue) { - _lazyInstance = instance ?? throw new System.ArgumentNullException("instance"); + _lazyInstance = instance ?? throw new System.ArgumentNullException(nameof(instance)); } /// /// Instance used to bind the member reference. @@ -2695,8 +2695,8 @@ internal sealed partial class LazyLockStatement : BaseLockStatement, ILockStatem public LazyLockStatement(Lazy lockedObject, Lazy body, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(isInvalid, syntax, type, constantValue) { - _lazyLockedObject = lockedObject ?? throw new System.ArgumentNullException("lockedObject"); - _lazyBody = body ?? throw new System.ArgumentNullException("body"); + _lazyLockedObject = lockedObject ?? throw new System.ArgumentNullException(nameof(lockedObject)); + _lazyBody = body ?? throw new System.ArgumentNullException(nameof(body)); } /// /// Value to be locked. @@ -2807,7 +2807,7 @@ internal sealed partial class LazyMethodBindingExpression : BaseMethodBindingExp public LazyMethodBindingExpression(IMethodSymbol method, bool isVirtual, Lazy instance, ISymbol member, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(method, isVirtual, member, isInvalid, syntax, type, constantValue) { - _lazyInstance = instance ?? throw new System.ArgumentNullException("instance"); + _lazyInstance = instance ?? throw new System.ArgumentNullException(nameof(instance)); } /// /// Instance of the type. Null if the reference is to a static/shared member. @@ -2873,8 +2873,8 @@ internal sealed partial class LazyNullCoalescingExpression : BaseNullCoalescingE public LazyNullCoalescingExpression(Lazy primaryOperand, Lazy secondaryOperand, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(isInvalid, syntax, type, constantValue) { - _lazyPrimaryOperand = primaryOperand ?? throw new System.ArgumentNullException("primaryOperand"); - _lazySecondaryOperand = secondaryOperand ?? throw new System.ArgumentNullException("secondaryOperand"); + _lazyPrimaryOperand = primaryOperand ?? throw new System.ArgumentNullException(nameof(primaryOperand)); + _lazySecondaryOperand = secondaryOperand ?? throw new System.ArgumentNullException(nameof(secondaryOperand)); } /// /// Value to be unconditionally evaluated. @@ -3043,7 +3043,7 @@ internal sealed partial class LazyParameterInitializer : BaseParameterInitialize public LazyParameterInitializer(IParameterSymbol parameter, Lazy value, OperationKind kind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(parameter, kind, isInvalid, syntax, type, constantValue) { - _lazyValue = value ?? throw new System.ArgumentNullException("value"); + _lazyValue = value ?? throw new System.ArgumentNullException(nameof(value)); } public override IOperation Value => _lazyValue.Value; } @@ -3120,7 +3120,7 @@ internal sealed partial class LazyParenthesizedExpression : BaseParenthesizedExp public LazyParenthesizedExpression(Lazy operand, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(isInvalid, syntax, type, constantValue) { - _lazyOperand = operand ?? throw new System.ArgumentNullException("operand"); + _lazyOperand = operand ?? throw new System.ArgumentNullException(nameof(operand)); } /// /// Operand enclosed in parentheses. @@ -3196,7 +3196,7 @@ internal sealed partial class LazyPointerIndirectionReferenceExpression : BasePo public LazyPointerIndirectionReferenceExpression(Lazy pointer, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(isInvalid, syntax, type, constantValue) { - _lazyPointer = pointer ?? throw new System.ArgumentNullException("pointer"); + _lazyPointer = pointer ?? throw new System.ArgumentNullException(nameof(pointer)); } /// /// Pointer to be dereferenced. @@ -3252,7 +3252,7 @@ internal sealed partial class LazyPropertyInitializer : BasePropertyInitializer, public LazyPropertyInitializer(IPropertySymbol initializedProperty, Lazy value, OperationKind kind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(initializedProperty, kind, isInvalid, syntax, type, constantValue) { - _lazyValue = value ?? throw new System.ArgumentNullException("value"); + _lazyValue = value ?? throw new System.ArgumentNullException(nameof(value)); } public override IOperation Value => _lazyValue.Value; } @@ -3335,8 +3335,8 @@ internal sealed partial class LazyPropertyReferenceExpression : BasePropertyRefe public LazyPropertyReferenceExpression(IPropertySymbol property, Lazy instance, ISymbol member, Lazy> argumentsInEvaluationOrder, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(property, member, isInvalid, syntax, type, constantValue) { - _lazyInstance = instance ?? throw new System.ArgumentNullException("instance"); - _lazyArgumentsInEvaluationOrder = argumentsInEvaluationOrder ?? throw new System.ArgumentNullException("argumentsInEvaluationOrder"); + _lazyInstance = instance ?? throw new System.ArgumentNullException(nameof(instance)); + _lazyArgumentsInEvaluationOrder = argumentsInEvaluationOrder ?? throw new System.ArgumentNullException(nameof(argumentsInEvaluationOrder)); } /// /// Instance of the type. Null if the reference is to a static/shared member. @@ -3421,8 +3421,8 @@ internal sealed partial class LazyRangeCaseClause : BaseRangeCaseClause, IRangeC public LazyRangeCaseClause(Lazy minimumValue, Lazy maximumValue, CaseKind caseKind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(caseKind, isInvalid, syntax, type, constantValue) { - _lazyMinimumValue = minimumValue ?? throw new System.ArgumentNullException("minimumValue"); - _lazyMaximumValue = maximumValue ?? throw new System.ArgumentNullException("maximumValue"); + _lazyMinimumValue = minimumValue ?? throw new System.ArgumentNullException(nameof(minimumValue)); + _lazyMaximumValue = maximumValue ?? throw new System.ArgumentNullException(nameof(maximumValue)); } /// /// Minimum value of the case range. @@ -3490,7 +3490,7 @@ internal sealed partial class LazyRelationalCaseClause : BaseRelationalCaseClaus public LazyRelationalCaseClause(Lazy value, BinaryOperationKind relation, CaseKind caseKind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(relation, caseKind, isInvalid, syntax, type, constantValue) { - _lazyValue = value ?? throw new System.ArgumentNullException("value"); + _lazyValue = value ?? throw new System.ArgumentNullException(nameof(value)); } /// /// Case value. @@ -3563,7 +3563,7 @@ internal sealed partial class LazyReturnStatement : BaseReturnStatement, IReturn public LazyReturnStatement(OperationKind kind, Lazy returnedValue, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(kind, isInvalid, syntax, type, constantValue) { - _lazyReturnedValue = returnedValue ?? throw new System.ArgumentNullException("returnedValue"); + _lazyReturnedValue = returnedValue ?? throw new System.ArgumentNullException(nameof(returnedValue)); } /// /// Value to be returned. @@ -3626,7 +3626,7 @@ internal sealed partial class LazySingleValueCaseClause : BaseSingleValueCaseCla public LazySingleValueCaseClause(Lazy value, BinaryOperationKind equality, CaseKind caseKind, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(equality, caseKind, isInvalid, syntax, type, constantValue) { - _lazyValue = value ?? throw new System.ArgumentNullException("value"); + _lazyValue = value ?? throw new System.ArgumentNullException(nameof(value)); } /// /// Case value. @@ -3802,7 +3802,7 @@ internal sealed partial class LazySwitchStatement : BaseSwitchStatement, ISwitch public LazySwitchStatement(Lazy value, Lazy> cases, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(isInvalid, syntax, type, constantValue) { - _lazyValue = value ?? throw new System.ArgumentNullException("value"); + _lazyValue = value ?? throw new System.ArgumentNullException(nameof(value)); _lazyCases = cases; } /// @@ -3881,7 +3881,7 @@ internal sealed partial class LazySyntheticLocalReferenceExpression : BaseSynthe public LazySyntheticLocalReferenceExpression(SyntheticLocalKind syntheticLocalKind, Lazy containingStatement, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(syntheticLocalKind, isInvalid, syntax, type, constantValue) { - _lazyContainingStatement = containingStatement ?? throw new System.ArgumentNullException("containingStatement"); + _lazyContainingStatement = containingStatement ?? throw new System.ArgumentNullException(nameof(containingStatement)); } /// /// Statement defining the lifetime of the synthetic local. @@ -3937,7 +3937,7 @@ internal sealed partial class LazyThrowStatement : BaseThrowStatement, IThrowSta public LazyThrowStatement(Lazy thrownObject, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(isInvalid, syntax, type, constantValue) { - _lazyThrownObject = thrownObject ?? throw new System.ArgumentNullException("thrownObject"); + _lazyThrownObject = thrownObject ?? throw new System.ArgumentNullException(nameof(thrownObject)); } /// /// Value to be thrown. @@ -4013,9 +4013,9 @@ internal sealed partial class LazyTryStatement : BaseTryStatement, ITryStatement public LazyTryStatement(Lazy body, Lazy> catches, Lazy finallyHandler, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(isInvalid, syntax, type, constantValue) { - _lazyBody = body ?? throw new System.ArgumentNullException("body"); + _lazyBody = body ?? throw new System.ArgumentNullException(nameof(body)); _lazyCatches = catches; - _lazyFinallyHandler = finallyHandler ?? throw new System.ArgumentNullException("finallyHandler"); + _lazyFinallyHandler = finallyHandler ?? throw new System.ArgumentNullException(nameof(finallyHandler)); } /// /// Body of the try, over which the handlers are active. @@ -4151,7 +4151,7 @@ internal sealed partial class LazyUnaryOperatorExpression : BaseUnaryOperatorExp public LazyUnaryOperatorExpression(UnaryOperationKind unaryOperationKind, Lazy operand, bool usesOperatorMethod, IMethodSymbol operatorMethod, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(unaryOperationKind, usesOperatorMethod, operatorMethod, isInvalid, syntax, type, constantValue) { - _lazyOperand = operand ?? throw new System.ArgumentNullException("operand"); + _lazyOperand = operand ?? throw new System.ArgumentNullException(nameof(operand)); } /// /// Single operand. @@ -4231,9 +4231,9 @@ internal sealed partial class LazyUsingStatement : BaseUsingStatement, IUsingSta public LazyUsingStatement(Lazy body, Lazy declaration, Lazy value, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(isInvalid, syntax, type, constantValue) { - _lazyBody = body ?? throw new System.ArgumentNullException("body"); - _lazyDeclaration = declaration ?? throw new System.ArgumentNullException("declaration"); - _lazyValue = value ?? throw new System.ArgumentNullException("value"); + _lazyBody = body ?? throw new System.ArgumentNullException(nameof(body)); + _lazyDeclaration = declaration ?? throw new System.ArgumentNullException(nameof(declaration)); + _lazyValue = value ?? throw new System.ArgumentNullException(nameof(value)); } /// /// Body of the using, over which the resources of the using are maintained. @@ -4307,7 +4307,7 @@ internal sealed partial class LazyVariableDeclaration : BaseVariableDeclaration, public LazyVariableDeclaration(ImmutableArray variables, Lazy initializer, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(variables, isInvalid, syntax, type, constantValue) { - _lazyInitializer = initializer ?? throw new System.ArgumentNullException("initializer"); + _lazyInitializer = initializer ?? throw new System.ArgumentNullException(nameof(initializer)); } /// @@ -4434,8 +4434,8 @@ internal sealed partial class LazyWhileUntilLoopStatement : BaseWhileUntilLoopSt public LazyWhileUntilLoopStatement(bool isTopTest, bool isWhile, Lazy condition, LoopKind loopKind, Lazy body, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(isTopTest, isWhile, loopKind, isInvalid, syntax, type, constantValue) { - _lazyCondition = condition ?? throw new System.ArgumentNullException("condition"); - _lazyBody = body ?? throw new System.ArgumentNullException("body"); + _lazyCondition = condition ?? throw new System.ArgumentNullException(nameof(condition)); + _lazyBody = body ?? throw new System.ArgumentNullException(nameof(body)); } /// /// Condition of the loop. @@ -4505,8 +4505,8 @@ internal sealed partial class LazyWithStatement : BaseWithStatement, IWithStatem public LazyWithStatement(Lazy body, Lazy value, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(isInvalid, syntax, type, constantValue) { - _lazyBody = body ?? throw new System.ArgumentNullException("body"); - _lazyValue = value ?? throw new System.ArgumentNullException("value"); + _lazyBody = body ?? throw new System.ArgumentNullException(nameof(body)); + _lazyValue = value ?? throw new System.ArgumentNullException(nameof(value)); } /// /// Body of the with. @@ -4573,7 +4573,7 @@ internal sealed partial class LazyLocalFunctionStatement : BaseLocalFunctionStat public LazyLocalFunctionStatement(IMethodSymbol localFunctionSymbol, Lazy body, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(localFunctionSymbol, isInvalid, syntax, type, constantValue) { - _lazyBody = body ?? throw new System.ArgumentNullException("body"); + _lazyBody = body ?? throw new System.ArgumentNullException(nameof(body)); } /// /// Body of the local function. @@ -4630,7 +4630,7 @@ internal sealed partial class LazyConstantPattern : BaseConstantPattern, IConsta public LazyConstantPattern(Lazy value, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(isInvalid, syntax, type, constantValue) { - _lazyValue = value ?? throw new System.ArgumentNullException("value"); + _lazyValue = value ?? throw new System.ArgumentNullException(nameof(value)); } /// /// Constant value of the pattern. @@ -4726,8 +4726,8 @@ internal sealed partial class LazyPatternCaseClause : BasePatternCaseClause, IPa public LazyPatternCaseClause(ILabelSymbol label, Lazy lazyPattern, Lazy lazyGuardExpression, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(label, isInvalid, syntax, type, constantValue) { - _lazyPattern = lazyPattern ?? throw new System.ArgumentNullException("lazyPattern"); - _lazyGuardExpression = lazyGuardExpression ?? throw new System.ArgumentNullException("lazyGuardExpression"); + _lazyPattern = lazyPattern ?? throw new System.ArgumentNullException(nameof(lazyPattern)); + _lazyGuardExpression = lazyGuardExpression ?? throw new System.ArgumentNullException(nameof(lazyGuardExpression)); } /// /// Pattern associated with case clause. @@ -4798,8 +4798,8 @@ internal sealed partial class LazyIsPatternExpression : BaseIsPatternExpression, public LazyIsPatternExpression(Lazy lazyExpression, Lazy lazyPattern, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(isInvalid, syntax, type, constantValue) { - _lazyExpression = lazyExpression ?? throw new System.ArgumentNullException("lazyExpression"); - _lazyPattern = lazyPattern ?? throw new System.ArgumentNullException("lazyPattern"); + _lazyExpression = lazyExpression ?? throw new System.ArgumentNullException(nameof(lazyExpression)); + _lazyPattern = lazyPattern ?? throw new System.ArgumentNullException(nameof(lazyPattern)); } /// /// Expression. diff --git a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt index 2abb18e15657a..3638da6190e77 100644 --- a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt +++ b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt @@ -1,9 +1,5 @@ *REMOVED*Microsoft.CodeAnalysis.Compilation.Emit(System.IO.Stream peStream, System.IO.Stream pdbStream = null, System.IO.Stream xmlDocumentationStream = null, System.IO.Stream win32Resources = null, System.Collections.Generic.IEnumerable manifestResources = null, Microsoft.CodeAnalysis.Emit.EmitOptions options = null, Microsoft.CodeAnalysis.IMethodSymbol debugEntryPoint = null, System.IO.Stream sourceLinkStream = null, System.Collections.Generic.IEnumerable embeddedTexts = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.Emit.EmitResult *REMOVED*Microsoft.CodeAnalysis.Emit.EmitOptions.EmitOptions(bool metadataOnly = false, Microsoft.CodeAnalysis.Emit.DebugInformationFormat debugInformationFormat = (Microsoft.CodeAnalysis.Emit.DebugInformationFormat)0, string pdbFilePath = null, string outputNameOverride = null, int fileAlignment = 0, ulong baseAddress = 0, bool highEntropyVirtualAddressSpace = false, Microsoft.CodeAnalysis.SubsystemVersion subsystemVersion = default(Microsoft.CodeAnalysis.SubsystemVersion), string runtimeMetadataVersion = null, bool tolerateErrors = false, bool includePrivateMembers = false, System.Collections.Immutable.ImmutableArray instrumentationKinds = default(System.Collections.Immutable.ImmutableArray)) -> void -*REMOVED*Microsoft.CodeAnalysis.Semantics.IAssignmentExpression.Target.get -> Microsoft.CodeAnalysis.IOperation -*REMOVED*Microsoft.CodeAnalysis.Semantics.IAssignmentExpression.Value.get -> Microsoft.CodeAnalysis.IOperation -*REMOVED*Microsoft.CodeAnalysis.Semantics.ICompoundAssignmentExpression.BinaryOperationKind.get -> Microsoft.CodeAnalysis.Semantics.BinaryOperationKind -*REMOVED*Microsoft.CodeAnalysis.Semantics.IPropertyReferenceExpression.Property.get -> Microsoft.CodeAnalysis.IPropertySymbol Microsoft.CodeAnalysis.CommandLineArguments.OutputRefFilePath.get -> string Microsoft.CodeAnalysis.CommandLineArguments.RuleSetPath.get -> string Microsoft.CodeAnalysis.CommandLineReference.CommandLineReference(string reference, Microsoft.CodeAnalysis.MetadataReferenceProperties properties) -> void diff --git a/src/Test/Utilities/Portable/Diagnostics/OperationTestAnalyzer.cs b/src/Test/Utilities/Portable/Diagnostics/OperationTestAnalyzer.cs index d0915bf86d28b..b1e16a15ebf1a 100644 --- a/src/Test/Utilities/Portable/Diagnostics/OperationTestAnalyzer.cs +++ b/src/Test/Utilities/Portable/Diagnostics/OperationTestAnalyzer.cs @@ -134,139 +134,149 @@ public sealed override ImmutableArray SupportedDiagnostics public sealed override void Initialize(AnalysisContext context) { - context.RegisterOperationAction( - (operationContext) => - { - ILoopStatement loop = (ILoopStatement)operationContext.Operation; - if (loop.LoopKind == LoopKind.For) - { - IForLoopStatement forLoop = (IForLoopStatement)loop; - IOperation forCondition = forLoop.Condition; + context.RegisterOperationAction(AnalyzeOperation, OperationKind.LoopStatement); + } - if (forCondition.Kind == OperationKind.BinaryOperatorExpression) - { - IBinaryOperatorExpression condition = (IBinaryOperatorExpression)forCondition; - IOperation conditionLeft = condition.LeftOperand; - IOperation conditionRight = condition.RightOperand; + private void AnalyzeOperation(OperationAnalysisContext operationContext) + { + ILoopStatement loop = (ILoopStatement)operationContext.Operation; + if (loop.LoopKind == LoopKind.For) + { + IForLoopStatement forLoop = (IForLoopStatement)loop; + IOperation forCondition = forLoop.Condition; - if (conditionRight.ConstantValue.HasValue && - conditionRight.Type.SpecialType == SpecialType.System_Int32 && - conditionLeft.Kind == OperationKind.LocalReferenceExpression) - { - // Test is known to be a comparison of a local against a constant. + if (forCondition.Kind == OperationKind.BinaryOperatorExpression) + { + IBinaryOperatorExpression condition = (IBinaryOperatorExpression)forCondition; + IOperation conditionLeft = condition.LeftOperand; + IOperation conditionRight = condition.RightOperand; - int testValue = (int)conditionRight.ConstantValue.Value; - ILocalSymbol testVariable = ((ILocalReferenceExpression)conditionLeft).Local; + if (conditionRight.ConstantValue.HasValue && + conditionRight.Type.SpecialType == SpecialType.System_Int32 && + conditionLeft.Kind == OperationKind.LocalReferenceExpression) + { + // Test is known to be a comparison of a local against a constant. - if (forLoop.Before.Length == 1) - { - IOperation setup = forLoop.Before[0]; - if (setup.Kind == OperationKind.ExpressionStatement && ((IExpressionStatement)setup).Expression.Kind == OperationKind.SimpleAssignmentExpression) - { - ISimpleAssignmentExpression setupAssignment = (ISimpleAssignmentExpression)((IExpressionStatement)setup).Expression; - if (setupAssignment.Target.Kind == OperationKind.LocalReferenceExpression && - ((ILocalReferenceExpression)setupAssignment.Target).Local == testVariable && - setupAssignment.Value.ConstantValue.HasValue && - setupAssignment.Value.Type.SpecialType == SpecialType.System_Int32) - { - // Setup is known to be an assignment of a constant to the local used in the test. + int testValue = (int)conditionRight.ConstantValue.Value; + ILocalSymbol testVariable = ((ILocalReferenceExpression)conditionLeft).Local; - int initialValue = (int)setupAssignment.Value.ConstantValue.Value; + if (forLoop.Before.Length == 1) + { + IOperation setup = forLoop.Before[0]; + if (setup.Kind == OperationKind.ExpressionStatement && ((IExpressionStatement)setup).Expression.Kind == OperationKind.SimpleAssignmentExpression) + { + ISimpleAssignmentExpression setupAssignment = (ISimpleAssignmentExpression)((IExpressionStatement)setup).Expression; + if (setupAssignment.Target.Kind == OperationKind.LocalReferenceExpression && + ((ILocalReferenceExpression)setupAssignment.Target).Local == testVariable && + setupAssignment.Value.ConstantValue.HasValue && + setupAssignment.Value.Type.SpecialType == SpecialType.System_Int32) + { + // Setup is known to be an assignment of a constant to the local used in the test. - if (forLoop.AtLoopBottom.Length == 1) - { - IOperation advance = forLoop.AtLoopBottom[0]; - if (advance.Kind == OperationKind.ExpressionStatement) - { - IOperation advanceExpression = ((IExpressionStatement)advance).Expression; - IOperation advanceIncrement = null; - BinaryOperationKind advanceOperationCode = BinaryOperationKind.None; - - if (advanceExpression.Kind == OperationKind.SimpleAssignmentExpression) - { - ISimpleAssignmentExpression advanceAssignment = (ISimpleAssignmentExpression)advanceExpression; - - if (advanceAssignment.Target.Kind == OperationKind.LocalReferenceExpression && - ((ILocalReferenceExpression)advanceAssignment.Target).Local == testVariable && - advanceAssignment.Value.Kind == OperationKind.BinaryOperatorExpression && - advanceAssignment.Value.Type.SpecialType == SpecialType.System_Int32) - { - // Advance is known to be an assignment of a binary operation to the local used in the test. - - IBinaryOperatorExpression advanceOperation = (IBinaryOperatorExpression)advanceAssignment.Value; - if (!advanceOperation.UsesOperatorMethod && - advanceOperation.LeftOperand.Kind == OperationKind.LocalReferenceExpression && - ((ILocalReferenceExpression)advanceOperation.LeftOperand).Local == testVariable && - advanceOperation.RightOperand.ConstantValue.HasValue && - advanceOperation.RightOperand.Type.SpecialType == SpecialType.System_Int32) - { - // Advance binary operation is known to involve a reference to the local used in the test and a constant. - advanceIncrement = advanceOperation.RightOperand; - advanceOperationCode = advanceOperation.BinaryOperationKind; - } - } - } - else if (advanceExpression.Kind == OperationKind.CompoundAssignmentExpression) - { - ICompoundAssignmentExpression advanceAssignment = (ICompoundAssignmentExpression)advanceExpression; - - if (advanceAssignment.Target.Kind == OperationKind.LocalReferenceExpression && - ((ILocalReferenceExpression)advanceAssignment.Target).Local == testVariable && - advanceAssignment.Value.ConstantValue.HasValue && - advanceAssignment.Value.Type.SpecialType == SpecialType.System_Int32) - { - // Advance binary operation is known to involve a reference to the local used in the test and a constant. - advanceIncrement = advanceAssignment.Value; - advanceOperationCode = advanceAssignment.BinaryOperationKind; - } - } - else if (advanceExpression.Kind == OperationKind.IncrementExpression) - { - IIncrementExpression advanceAssignment = (IIncrementExpression)advanceExpression; - - if (advanceAssignment.Target.Kind == OperationKind.LocalReferenceExpression && - ((ILocalReferenceExpression)advanceAssignment.Target).Local == testVariable) - { - // Advance binary operation is known to involve a reference to the local used in the test and a constant. - advanceIncrement = CreateIncrementOneLiteralExpression(advanceAssignment); - advanceOperationCode = CSharpOperationFactory.Helper.DeriveBinaryOperationKind(advanceAssignment.IncrementOperationKind); - } - } - - if (advanceIncrement != null) - { - int incrementValue = (int)advanceIncrement.ConstantValue.Value; - if (advanceOperationCode == BinaryOperationKind.IntegerSubtract) - { - advanceOperationCode = BinaryOperationKind.IntegerAdd; - incrementValue = -incrementValue; - } - - if (advanceOperationCode == BinaryOperationKind.IntegerAdd && - incrementValue != 0 && - (condition.BinaryOperationKind == BinaryOperationKind.IntegerLessThan || - condition.BinaryOperationKind == BinaryOperationKind.IntegerLessThanOrEqual || - condition.BinaryOperationKind == BinaryOperationKind.IntegerNotEquals || - condition.BinaryOperationKind == BinaryOperationKind.IntegerGreaterThan || - condition.BinaryOperationKind == BinaryOperationKind.IntegerGreaterThanOrEqual)) - { - int iterationCount = (testValue - initialValue) / incrementValue; - if (iterationCount >= 1000000) - { - Report(operationContext, forLoop.Syntax, BigForDescriptor); - } - } - } - } - } - } - } - } - } - } - } - }, - OperationKind.LoopStatement); + int initialValue = (int)setupAssignment.Value.ConstantValue.Value; + + if (forLoop.AtLoopBottom.Length == 1) + { + IOperation advance = forLoop.AtLoopBottom[0]; + if (advance.Kind == OperationKind.ExpressionStatement) + { + IOperation advanceExpression = ((IExpressionStatement)advance).Expression; + + IOperation advanceIncrement; + BinaryOperationKind advanceOperationCode; + GetOperationKindAndValue(testVariable, advanceExpression, out advanceOperationCode, out advanceIncrement); + + if (advanceIncrement != null) + { + int incrementValue = (int)advanceIncrement.ConstantValue.Value; + if (advanceOperationCode == BinaryOperationKind.IntegerSubtract) + { + advanceOperationCode = BinaryOperationKind.IntegerAdd; + incrementValue = -incrementValue; + } + + if (advanceOperationCode == BinaryOperationKind.IntegerAdd && + incrementValue != 0 && + (condition.BinaryOperationKind == BinaryOperationKind.IntegerLessThan || + condition.BinaryOperationKind == BinaryOperationKind.IntegerLessThanOrEqual || + condition.BinaryOperationKind == BinaryOperationKind.IntegerNotEquals || + condition.BinaryOperationKind == BinaryOperationKind.IntegerGreaterThan || + condition.BinaryOperationKind == BinaryOperationKind.IntegerGreaterThanOrEqual)) + { + int iterationCount = (testValue - initialValue) / incrementValue; + if (iterationCount >= 1000000) + { + Report(operationContext, forLoop.Syntax, BigForDescriptor); + } + } + } + } + } + } + } + } + } + } + } + } + + private void GetOperationKindAndValue( + ILocalSymbol testVariable, IOperation advanceExpression, + out BinaryOperationKind advanceOperationCode, out IOperation advanceIncrement) + { + advanceIncrement = null; + advanceOperationCode = BinaryOperationKind.None; + + if (advanceExpression.Kind == OperationKind.SimpleAssignmentExpression) + { + ISimpleAssignmentExpression advanceAssignment = (ISimpleAssignmentExpression)advanceExpression; + + if (advanceAssignment.Target.Kind == OperationKind.LocalReferenceExpression && + ((ILocalReferenceExpression)advanceAssignment.Target).Local == testVariable && + advanceAssignment.Value.Kind == OperationKind.BinaryOperatorExpression && + advanceAssignment.Value.Type.SpecialType == SpecialType.System_Int32) + { + // Advance is known to be an assignment of a binary operation to the local used in the test. + + IBinaryOperatorExpression advanceOperation = (IBinaryOperatorExpression)advanceAssignment.Value; + if (!advanceOperation.UsesOperatorMethod && + advanceOperation.LeftOperand.Kind == OperationKind.LocalReferenceExpression && + ((ILocalReferenceExpression)advanceOperation.LeftOperand).Local == testVariable && + advanceOperation.RightOperand.ConstantValue.HasValue && + advanceOperation.RightOperand.Type.SpecialType == SpecialType.System_Int32) + { + // Advance binary operation is known to involve a reference to the local used in the test and a constant. + advanceIncrement = advanceOperation.RightOperand; + advanceOperationCode = advanceOperation.BinaryOperationKind; + } + } + } + else if (advanceExpression.Kind == OperationKind.CompoundAssignmentExpression) + { + ICompoundAssignmentExpression advanceAssignment = (ICompoundAssignmentExpression)advanceExpression; + + if (advanceAssignment.Target.Kind == OperationKind.LocalReferenceExpression && + ((ILocalReferenceExpression)advanceAssignment.Target).Local == testVariable && + advanceAssignment.Value.ConstantValue.HasValue && + advanceAssignment.Value.Type.SpecialType == SpecialType.System_Int32) + { + // Advance binary operation is known to involve a reference to the local used in the test and a constant. + advanceIncrement = advanceAssignment.Value; + advanceOperationCode = advanceAssignment.BinaryOperationKind; + } + } + else if (advanceExpression.Kind == OperationKind.IncrementExpression) + { + IIncrementExpression advanceAssignment = (IIncrementExpression)advanceExpression; + + if (advanceAssignment.Target.Kind == OperationKind.LocalReferenceExpression && + ((ILocalReferenceExpression)advanceAssignment.Target).Local == testVariable) + { + // Advance binary operation is known to involve a reference to the local used in the test and a constant. + advanceIncrement = CreateIncrementOneLiteralExpression(advanceAssignment); + advanceOperationCode = CSharpOperationFactory.Helper.DeriveBinaryOperationKind(advanceAssignment.IncrementOperationKind); + } + } } private static ILiteralExpression CreateIncrementOneLiteralExpression(IIncrementExpression increment) From c2fcba9d9c63e4b7e9fc017e34ba6807be194837 Mon Sep 17 00:00:00 2001 From: Heejae Chang Date: Thu, 29 Jun 2017 20:39:28 -0700 Subject: [PATCH 16/16] missed adding simple to one comment --- .../Core/Portable/Generated/Operations.xml.Generated.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs index 46e952e3a642b..d32f9490d1770 100644 --- a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs +++ b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs @@ -423,7 +423,7 @@ public SimpleAssignmentExpression(IOperation target, IOperation value, bool isIn } /// - /// Represents an assignment expression. + /// Represents a simple assignment expression. /// internal sealed partial class LazySimpleAssignmentExpression : BaseSimpleAssignmentExpression, ISimpleAssignmentExpression {