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 Convert nodes added by VB.NET in cases involving constrained generic type parameters #1068

Merged
merged 3 commits into from
Oct 11, 2020

Conversation

stakx
Copy link
Contributor

@stakx stakx commented Oct 11, 2020

This should fix #1067.

I'll probably have to run a few more checks on whether it's really safe to blindly remove all type conversion nodes in MatcherFactory before merging this.

@stakx stakx added this to the 4.15.0 milestone Oct 11, 2020
@stakx stakx force-pushed the superfluous-vb-conversion-exprs branch 2 times, most recently from a9092a2 to 4f807e8 Compare October 11, 2020 11:32
It appears that VB.NET adds a pair of `Convert` nodes to expression
trees for constrained generic type parameters. Those double conversions
can end up "hiding" matchers thus wrapped from Moq's `MatcherFactory`.
The existing code in `MatcherFactory` unwraps only one conversion node
to get at matchers etc. This is not enough in the scenario documented
in the previous commit's failing test, which causes two conversion nodes
to be present.

This bug fix assumes that any conversion nodes present are only there
to satisfy the compiler's static type checks, but that they are irrele-
vant (and can thus be removed) for any analysis that needs to be done
to identify a suitable matcher.

(It might be safer to not simply remove any conversion node blindly,
but instead target this very specific VB.NET pattern and deal with it
as a special case.)
@stakx stakx force-pushed the superfluous-vb-conversion-exprs branch from 4f807e8 to c171d2e Compare October 11, 2020 15:15
@stakx stakx merged commit 7827365 into devlooped:master Oct 11, 2020
@stakx stakx deleted the superfluous-vb-conversion-exprs branch October 11, 2020 15:19
@stakx stakx modified the milestones: 4.15.0, 4.14.7 Oct 14, 2020
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.

Callback not raised in mocked subclass
1 participant