Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Using named parameter syntax when passing literals in System.Linq.Expressions #13046

Merged

Conversation

bartdesmet
Copy link
Contributor

Used a Roslyn analyzer and code fix provider to find method invocations where the last 1..N arguments are false, true, or null literals without named parameter syntax. When found, the code fix rewrites them to include the parameter name.

I've applied the suggested changes pretty much everywhere, with the exception of the Push method in the interpreter, when we push null to the evaluation stack. That's pretty clear from context given it's the only argument.

I didn't want to deal with literals that occur in the middle of an argument list, to avoid worries about reordering evaluation and other complexities. I'll revisit that one day while also addressing indexers, delegate invocation, and object creation nodes.

CC @stephentoub

@@ -1678,9 +1678,9 @@ public static BinaryExpression AddChecked(Expression left, Expression right, Met
{
return new SimpleBinaryExpression(ExpressionType.AddChecked, left, right, left.Type);
}
return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.AddChecked, "op_Addition", left, right, false);
return GetUserDefinedBinaryOperatorOrThrow(ExpressionType.AddChecked, "op_Addition", left, right, liftToNull: false);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the only method passing false for liftToNull for no obvious reason. Tracking this in https://github.com/dotnet/corefx/issues/13048.

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks, @bartdesmet.

@stephentoub stephentoub merged commit af76b7b into dotnet:master Oct 27, 2016
@karelz karelz modified the milestone: 1.2.0 Dec 3, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants