-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Add and implement IImplicitIndexerReferenceOperation
#58200
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
Conversation
| <Node Name="IImplicitIndexerReferenceOperation" Base="IOperation" ChildrenOrder="Instance,Argument" HasType="true"> | ||
| <Comments> | ||
| <summary> | ||
| Represents a reference to an implicit System.Index or System.Range indexer over non-array type. |
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.
| <Property Name="LengthSymbol" Type="ISymbol"> | ||
| <Comments> | ||
| <summary> | ||
| The <c>Length</c> or <c>Count</c> property that can be used to fetch the length 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.
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.
Perhaps will be used?
I intentionally used "can" because we might never use it. It all depends.
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.
In that case, I think might sounds better. But it's ok to leave as is if you prefer.
| <Property Name="IndexerSymbol" Type="ISymbol"> | ||
| <Comments> | ||
| <summary> | ||
| Symbol for the underlying indexer or a slice method that is being used to implement the implicit indexer. |
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.
| IOperation argument = VisitRequired(operation.Argument); | ||
| IOperation instance = PopOperand(); | ||
| PopStackFrame(frame); | ||
| return new ImplicitIndexerReferenceOperation(instance, argument, operation.LengthSymbol, operation.IndexerSymbol, semanticModel: null, |
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.
Should we be lowering the indexer to its final form here? I would have somewhat expected it to be turned into the series of method/property calls that make up an indexer. #Resolved
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.
Should we be lowering the indexer to its final form here? I would have somewhat expected it to be turned into the series of method/property calls that make up an indexer.
There is no requirement to lower things in CFG. We can accurately reflect the control flow by using the original node.
333fred
left a comment
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 (commit 2) with minor doc adjustments.
|
@dotnet/roslyn-compiler For the second review. |
|
@dotnet/roslyn-compiler For the second review. |
1 similar comment
|
@dotnet/roslyn-compiler For the second review. |
jcouv
left a comment
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.
Compiler side LGTM (iteration 4). Not sure what the IDE portion has to do with this PR, consider splitting.
|
|
||
| [CompilerTrait(CompilerFeature.IOperation, CompilerFeature.Dataflow)] | ||
| [Fact] | ||
| public void ImplicitIndexIndexer_ControlFlowInInstanceAndArgument_String() |
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.
Thanks much for the descriptive test names. It's much easier to follow the purpose than numbers
Unfortunately CI is failing without these changes. Apparently analyzers are able to make sense of more code after the IOperation change and are able to detect more violations. |
Closes #58079.