Skip to content

Conversation

@AlekseyTs
Copy link
Contributor

Closes #58079.

<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.
Copy link
Member

@333fred 333fred Dec 9, 2021

Choose a reason for hiding this comment

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

Missing an a: over a non-array #Resolved

<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.
Copy link
Member

@333fred 333fred Dec 9, 2021

Choose a reason for hiding this comment

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

can

Perhaps will be used? #Resolved

Copy link
Contributor Author

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.

Copy link
Member

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.
Copy link
Member

@333fred 333fred Dec 9, 2021

Choose a reason for hiding this comment

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

being

being could be removed. #Resolved

IOperation argument = VisitRequired(operation.Argument);
IOperation instance = PopOperand();
PopStackFrame(frame);
return new ImplicitIndexerReferenceOperation(instance, argument, operation.LengthSymbol, operation.IndexerSymbol, semanticModel: null,
Copy link
Member

@333fred 333fred Dec 9, 2021

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

Copy link
Contributor Author

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.

Copy link
Member

@333fred 333fred left a 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.

@AlekseyTs AlekseyTs requested a review from a team as a code owner December 9, 2021 16:41
@AlekseyTs
Copy link
Contributor Author

@dotnet/roslyn-compiler For the second review.

@AlekseyTs
Copy link
Contributor Author

@dotnet/roslyn-compiler For the second review.

1 similar comment
@AlekseyTs
Copy link
Contributor Author

@dotnet/roslyn-compiler For the second review.

Copy link
Member

@jcouv jcouv left a 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()
Copy link
Member

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

@jcouv jcouv self-assigned this Dec 11, 2021
@AlekseyTs
Copy link
Contributor Author

Not sure what the IDE portion has to do with this PR, consider splitting.

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.

@AlekseyTs AlekseyTs merged commit f36574c into dotnet:main Dec 13, 2021
@ghost ghost added this to the Next milestone Dec 13, 2021
@Cosifne Cosifne modified the milestones: Next, 17.1.P3 Jan 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IOperation support for implicit Index/Range indexer over non-array types

4 participants