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

Fix ExpressionStringBuilder formatting of indexer assignment #880

Merged
merged 2 commits into from
Aug 8, 2019

Conversation

stakx
Copy link
Contributor

@stakx stakx commented Aug 8, 2019

In some cases, ExpressionStringBuilder will format an indexer assignment expression x => x[i1, i2] = v incorrectly as x => x[i1, i2, v] = v.

@stakx stakx added this to the 4.13.0 milestone Aug 8, 2019
@@ -325,7 +325,7 @@ private void ToStringMethodCall(MethodCallExpression node)
else if (node.Method.IsPropertyIndexerSetter())
{
this.builder.Append('[');
AsCommaSeparatedValues(node.Arguments.Skip(paramFrom), ToString);
AsCommaSeparatedValues(node.Arguments.Skip(paramFrom).Take(node.Arguments.Count - paramFrom - 1), ToString);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It might be nice to have some kind of .Slice(...) extension method, but let's first see whether there would be other use cases in the Moq code base for it. Or, perhaps wait for C# 8 ranges.

@stakx stakx merged commit 7a5a7ce into devlooped:master Aug 8, 2019
@stakx stakx deleted the expressionstringbuilder branch August 8, 2019 20:41
@devlooped devlooped locked and limited conversation to collaborators Sep 6, 2024
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.

1 participant