Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactored IAssignment/ICompoundAssignment as we discussed and removed IndexPropertyReference #20431

Merged
merged 16 commits into from
Jun 30, 2017
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ public LazyArrayInitializer(Lazy<ImmutableArray<IOperation>> elementValues, bool
/// <summary>
/// Represents an assignment expression.
/// </summary>
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<object> constantValue) :
base(kind, isInvalid, syntax, type, constantValue)
Expand Down Expand Up @@ -778,7 +778,7 @@ public LazyCatchClause(Lazy<IBlockStatement> handler, ITypeSymbol caughtType, La
/// <summary>
/// Represents an assignment expression that includes a binary operation.
/// </summary>
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<object> constantValue) :
base(kind, isInvalid, syntax, type, constantValue)
Expand Down Expand Up @@ -3336,7 +3336,7 @@ public override TResult Accept<TArgument, TResult>(OperationVisitor<TArgument, T
/// <summary>
/// Represents a reference to a property.
/// </summary>
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<object> constantValue) :
base(member, kind, isInvalid, syntax, type, constantValue)
Expand Down
15 changes: 13 additions & 2 deletions src/Compilers/Core/Portable/Operations/IAssignmentExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
namespace Microsoft.CodeAnalysis.Semantics
{
/// <summary>
/// Represents an assignment expression.
/// Represents a base interface for assignment expressions.
/// </summary>
/// <remarks>
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
/// </remarks>
public interface IAssignmentExpression : IOperation
public interface IBaseAssignmentExpression : IOperation
{
/// <summary>
/// Target of the assignment.
Expand All @@ -22,5 +22,16 @@ public interface IAssignmentExpression : IOperation
/// </summary>
IOperation Value { get; }
}

/// <summary>
/// Represents an assignment expression.
/// </summary>
/// <remarks>
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
/// </remarks>
public interface IAssignmentExpression : IBaseAssignmentExpression
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What code will be consuming or implementing IAssignmentExpression rather than IBaseAssignmentExpression?

{
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,29 @@
namespace Microsoft.CodeAnalysis.Semantics
{
/// <summary>
/// Represents an assignment expression that includes a binary operation.
/// Represents a base interface for assignment expression that includes a binary operation.
/// </summary>
/// <remarks>
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
/// </remarks>
public interface ICompoundAssignmentExpression : IAssignmentExpression, IHasOperatorMethodExpression
public interface IBaseCompoundAssignmentExpression : IBaseAssignmentExpression, IHasOperatorMethodExpression
{
/// <summary>
/// Kind of binary operation.
/// </summary>
BinaryOperationKind BinaryOperationKind { get; }
}

/// <summary>
/// Represents an assignment expression that includes a binary operation.
/// </summary>
/// <remarks>
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
/// </remarks>
public interface ICompoundAssignmentExpression : IBaseCompoundAssignmentExpression
{
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -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.
/// </remarks>
public interface IIncrementExpression : ICompoundAssignmentExpression
public interface IIncrementExpression : IBaseCompoundAssignmentExpression
{
/// <summary>
/// Kind of increment.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
/// </remarks>
public interface IIndexedPropertyReferenceExpression : IPropertyReferenceExpression, IHasArgumentsExpression
public interface IIndexedPropertyReferenceExpression : IBasePropertyReferenceExpression, IHasArgumentsExpression
{
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,29 @@
namespace Microsoft.CodeAnalysis.Semantics
{
/// <summary>
/// Represents a reference to a property.
/// Represents a base interface for reference to a property.
/// </summary>
/// <remarks>
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
/// </remarks>
public interface IPropertyReferenceExpression : IMemberReferenceExpression
public interface IBasePropertyReferenceExpression : IMemberReferenceExpression
{
/// <summary>
/// Referenced property.
/// </summary>
IPropertySymbol Property { get; }
}

/// <summary>
/// Represents a reference to a property.
/// </summary>
/// <remarks>
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
/// </remarks>
public interface IPropertyReferenceExpression : IBasePropertyReferenceExpression
{
}
}

15 changes: 11 additions & 4 deletions src/Compilers/Core/Portable/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -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<Microsoft.CodeAnalysis.ResourceDescription> manifestResources = null, Microsoft.CodeAnalysis.Emit.EmitOptions options = null, Microsoft.CodeAnalysis.IMethodSymbol debugEntryPoint = null, System.IO.Stream sourceLinkStream = null, System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.EmbeddedText> 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<Microsoft.CodeAnalysis.Emit.InstrumentationKind> instrumentationKinds = default(System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Emit.InstrumentationKind>)) -> void
*REMOVED*Microsoft.CodeAnalysis.Semantics.IPropertyReferenceExpression.Property.get -> Microsoft.CodeAnalysis.IPropertySymbol
*REMOVED*Microsoft.CodeAnalysis.Semantics.IAssignmentExpression.Target.get -> Microsoft.CodeAnalysis.IOperation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did IOperations APIs previously ship?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me take a look. we did ship it under feature flag though

*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
Expand Down Expand Up @@ -347,10 +351,15 @@ Microsoft.CodeAnalysis.Semantics.IArrayElementReferenceExpression.Indices.get ->
Microsoft.CodeAnalysis.Semantics.IArrayInitializer
Microsoft.CodeAnalysis.Semantics.IArrayInitializer.ElementValues.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.IOperation>
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.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
Expand All @@ -369,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
Expand Down Expand Up @@ -503,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down