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

Replace parameter list comparison extension methods #676

Merged
merged 7 commits into from
Sep 4, 2018

Conversation

stakx
Copy link
Contributor

@stakx stakx commented Sep 4, 2018

There are currently several different ways in the Moq code base for comparing ordered lists of (parameter) types:

  • Enumerable.SequenceEqual
  • Enumerable.SequenceEqual + AssignmentCompatibilityTypeComparer
  • Extensions.HasSameParameterTypesAs
  • Extensions.HasCompatibleParameterTypes
  • Extensions.HasCompatibleParameterList

This refactoring replaces all of the above with three new composable building blocks:

  • ParameterTypes — wrapper for ParameterInfo[] so it can be treated like Type[]
  • Extensions.GetParameterTypes — gets a MethodInfo's parameter types as a ParameterTypes
  • Extensions.CompareTo — compares any pair of Type[] or ParameterTypes using either of two comparison modes: equality, or assignment-from-compatibility.

Care has been taken to keep them fast, and free of any heap allocations.

The check being removed here was introduced by devlooped#335, which fixed a
regression by reproducing type matching logic from the .NET reference
source for `Type.GetMethod(string, BindingFlags, Binder, Type[], ..)`.

This check is likely not needed, and we have no test that demonstrates
why it might be needed.

Removing this special check however will allow us to merge the method
it appears in with other similar methods.
@stakx stakx merged commit 1e2397b into devlooped:master Sep 4, 2018
@stakx stakx deleted the parameter-list-comparisons branch September 4, 2018 19:33
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