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

IOperation Node Porting: Non-Leaf Non-Hierarchy Nodes Pt3 #48892

Merged
merged 26 commits into from
Nov 2, 2020

Conversation

333fred
Copy link
Member

@333fred 333fred commented Oct 23, 2020

This is the next set of non-leaf, non-hierarchy IOperation nodes. With this PR, we're ~55% of the way through the types defined in OperationInterfaces.xml. Once again, commit-by-commit is recommended. You might be able to get away with doing a few commits at a time, but reviewing this all at once is likely to be very hard to do (given that there are 28 ported nodes in this PR).

@333fred 333fred changed the title nodes pt4 IOperation Node Porting: Non-Leaf Non-Hierarchy Nodes Pt3 Oct 23, 2020
@333fred 333fred added the Feature - IOperation IOperation label Oct 26, 2020
@333fred 333fred marked this pull request as ready for review October 26, 2020 16:39
@333fred 333fred requested a review from a team as a code owner October 26, 2020 16:39
@333fred
Copy link
Member Author

333fred commented Oct 26, 2020

@dotnet/roslyn-compiler @jcouv @jaredpar this is ready for review.

@333fred
Copy link
Member Author

333fred commented Oct 27, 2020

@dotnet/roslyn-ide 456829a (#48892) marks IArgumentOperation.ParameterSymbol as nullable, because it can be if the argument is __arglist. However, this causes issues with the InlineMethodRefactoring, which assumes that IArgumentOperation.ParameterSymbol will never return null. The fix here isn't readily apparent to me: is there a simply way to block __arglist in this refactoring so we can assume it's never nullable?

@333fred
Copy link
Member Author

333fred commented Oct 28, 2020

@dotnet/roslyn-ide 456829a (#48892) marks IArgumentOperation.ParameterSymbol as nullable, because it can be if the argument is __arglist. However, this causes issues with the InlineMethodRefactoring, which assumes that IArgumentOperation.ParameterSymbol will never return null. The fix here isn't readily apparent to me: is there a simply way to block __arglist in this refactoring so we can assume it's never nullable?

@CyrusNajmabadi or @jasonmalinowski any pointers?

@jasonmalinowski
Copy link
Member

Somewhere in

if (calleeMethodSymbol == null)
{
return;
}
if (calleeMethodSymbol.PartialImplementationPart != null)
{
calleeMethodSymbol = calleeMethodSymbol.PartialImplementationPart;
}
if (!calleeMethodSymbol.IsOrdinaryMethod() && !calleeMethodSymbol.IsExtensionMethod)
{
return;
}
if (calleeMethodSymbol.DeclaredAccessibility != Accessibility.Private)
{
return;
}
maybe?

@jcouv jcouv self-assigned this Oct 29, 2020
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 portion LGTM Thanks (iteration 26)

@333fred
Copy link
Member Author

333fred commented Oct 29, 2020

@dotnet/roslyn-ide can I get a review on the IDE portions of this change? For the IDE sections, it's probably easiest to not review commit by commit, and instead just review all of it at once as there are not that many.

@@ -60,7 +60,7 @@ private static ExpressionSyntax AsExpressionSyntax(IOperation operation)
=> operation switch
{
IReturnOperation { ReturnedValue: { } value } => (ExpressionSyntax)value.Syntax,
IThrowOperation op => ThrowExpression((ExpressionSyntax)op.Exception.Syntax),
IThrowOperation { Exception: { } exception } => ThrowExpression((ExpressionSyntax)exception.Syntax),
Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

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

IDE side lgtm.

@cston
Copy link
Member

cston commented Oct 30, 2020

                if (Reference is not null) builder.Add(Reference);

Could use builder.AddIfNotNull(Reference).


Refers to: src/Compilers/Core/Portable/Generated/Operations.Generated.cs:5798 in 2942c0f. [](commit_id = 2942c0f, deletion_comment = False)

@cston
Copy link
Member

cston commented Oct 30, 2020

                if (!ElementValues.IsEmpty) builder.AddRange(ElementValues);

Consider omitting the check. It's not clear that it saves any cycles.


Refers to: src/Compilers/Core/Portable/Generated/Operations.Generated.cs:6235 in 2942c0f. [](commit_id = 2942c0f, deletion_comment = False)

@cston
Copy link
Member

cston commented Oct 30, 2020

                Interlocked.CompareExchange(ref _lazyChildren, builder.ToImmutableAndFree(), null);

Since _lazyChildren is an IEnumerable<IOperation>, we're allocating an extra instance for the value, even for the empty case, because of boxing. Consider using builder.ToArrayAndFree() instead.


Refers to: src/Compilers/Core/Portable/Generated/Operations.Generated.cs:5799 in 2942c0f. [](commit_id = 2942c0f, deletion_comment = False)

Copy link
Member

@cston cston left a comment

Choose a reason for hiding this comment

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

A few comments, none blocking.

@333fred 333fred merged commit fc6baf4 into dotnet:features/ioperation Nov 2, 2020
@333fred 333fred deleted the nodes-pt4 branch November 2, 2020 19:25
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.

6 participants