-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Conversation
…to sit on top of IBaseAssignmentExpression rather than IAssignmentExpression
@dotnet/analyzer-ioperation @dotnet/roslyn-analysis can you take a look? |
@jinujoseph I think we had a bug about this, but I couldn't find it. do you know what that is? |
@AlekseyTs @cston @jinujoseph how do you think about this change? |
@mavasani has this wok item - #18056 (comment) which is this We need to simplify the hierarchy, The intend here is we are not going to have the complex inheritance hierarchy where in the same hierarchy there is lot of base. We should try to make it more flat and narrow. IExpression might have Iincrementexpression, IcompondAssignment , IAssignementExpression and those themselves can implement side hierarchy, which can be call as infos which are not Ioperation Kind , Say IAssignmentInfos and some one can uniformally operate on this things. I dont believe we can make IOperation hierarchy flat since we have cases such as ICaseClause where we want to return base type (ICaseClauses) when needed. but we can make IIncrementExpression, ICoumpoundAssignment, IAssignmentExpression to IHasXXXX pattern if want to. but I believe we can address that in different PR, this PR at least remove those odd cases where an interface are based interface for other interface and at the same time, itself has implementation. |
/// 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 |
There was a problem hiding this comment.
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
?
@mavasani @dotnet/analyzer-ioperation can you take a look? |
@AlekseyTs can you take a look at this PR? |
@dotnet/roslyn-infrastructure this seems happening in multiple PR. |
@dotnet/roslyn-infrastructure test failed |
retest windows_debug_vs-integration_prtest please |
@AlekseyTs is on vacation. can @cston @jcouv take a look? I talked about the design with @AlekseyTs and following his suggestion. IAssignmentExpression is now purely used as base interface, implementation only exist for SimpleAssignment and CompoundAssignment. InncrementExpression no longer inherit from CompoundAssignment. and it is its own type. IndexedPropertyReference and PropertyReference is merged and Argument return > 0 if it is indexed property. |
cc @dotnet/roslyn-compiler |
ping? can I get one more sign off from compiler team |
@@ -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.IAssignmentExpression.Target.get -> Microsoft.CodeAnalysis.IOperation |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
@@ -385,10 +385,29 @@ internal abstract partial class BaseAssignmentExpression : Operation, IAssignmen | |||
/// <summary> | |||
/// Represents an assignment expression. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// a simple assignment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
} | ||
|
||
/// <summary> | ||
/// Represents an assignment expression. | ||
/// </summary> | ||
internal sealed partial class LazyAssignmentExpression : BaseAssignmentExpression, IAssignmentExpression | ||
internal sealed partial class LazySimpleAssignmentExpression : BaseSimpleAssignmentExpression, ISimpleAssignmentExpression | ||
{ | ||
private readonly Lazy<IOperation> _lazyTarget; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a general question about the lazy pattern in IOperations, why not just implement this as:
class Lazy { private readonly Lazy<SimpleAssignmentExpression>; ... }
Do we expect that the different lazy parts with materialized separately?
[not blocking this PR]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't want to realize all children at some for example blocks.
by the way, this Lazy pattern is ver 1. so that we can share one implementation for both C# and VB. we might later move this to C#/VB explicit type that directly hold on to bound node that implements common IOperation interface for laziness. (more perf optimized version)
we decide this way since interface is the public API and implementation we can change later.
{ | ||
InitializedProperty = initializedProperty; | ||
_lazyValue = value ?? throw new System.ArgumentNullException("value"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nameof(value) instead of "value"
Same for other other instances of throw ArgumentNullException
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure.
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related to this PR, but this method is getting quite deep. Consider refactoring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@dotnet/roslyn-infrastructure windows_debug_vs-integration_prtest failed due to vsix installation. looks like busted in multiple PR |
refactored IAssignment/ICoumoundAssignment as we discussed. broke out IncrementalExpression from assignment expression.
merged Indexed and normal propertyreference expression and removed IndexedProperty interface.
also, made more code to use same patterns.