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

Remove superfluous .StripConversion helper method #631

Merged
merged 5 commits into from
Jun 15, 2018

Conversation

stakx
Copy link
Contributor

@stakx stakx commented Jun 15, 2018

This is a continuation of #629.

There's a helper method ExpressionExtensions.StripConversion(this LambdaExpression) that doesn't appear to have any effect whatsoever. It can be turned into an identity function and none of the unit tests break.

A closer inspection reveals the following:

  • The comment it contains about the LambdaExpression ctor introducing a cast no longer appears to hold true today. Also, the reference to ProtectedMockExtensions is rather vague. It looks a lot like things have changed so much since this code was added that it just no longer makes any sense.

  • The method is used only in diagnostic scenarios (i.e. when an exception is about to be thrown). It is strange that automatically added conversions would only have to be removed when we're about to error already, but not in normal operation. So if it's not needed during normal operation, it is very probably that we can remove it for diagnostics, too.

`AreSameMethod` is only used in one location (inside `VerifyCalls`),
move it there by making it a local function. This in turn makes it
more obvious that `StripConversion` as used in `AreSameMethod` is used
for purely diagnostic purposes here as well.
Why should `AreSameMethod` be the only location where something like
`StripConversion` is needed? None of the code paths leading up to the
much more important `MethodCall.IsEqualMethodOrOverride` do any cast
removal. So if we don't need this in other places, it's very probably
superfluous here, too.
@stakx stakx merged commit e4b288e into devlooped:master Jun 15, 2018
@stakx stakx deleted the remove-stripconversion branch June 15, 2018 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant