-
-
Notifications
You must be signed in to change notification settings - Fork 844
mock.Protected().Setup<int>("Foo") fails base implementation of Foo is hidden in the derived class #1342
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
base: main
Are you sure you want to change the base?
mock.Protected().Setup<int>("Foo") fails base implementation of Foo is hidden in the derived class #1342
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -326,8 +326,24 @@ private static MethodInfo GetMethod(string methodName, Type[] genericTypeArgumen | |||||||||||||
| .Select(m => m.MakeGenericMethod(genericTypeArguments)); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| return methods | ||||||||||||||
| .SingleOrDefault(m => m.GetParameterTypes().CompareTo(argTypes, exact, considerTypeMatchers: false)); | ||||||||||||||
| methods = methods.Where(m => m.GetParameterTypes().CompareTo(argTypes, exact, considerTypeMatchers: false)); | ||||||||||||||
|
|
||||||||||||||
| if (methods.Count() < 2) | ||||||||||||||
|
Comment on lines
+329
to
+331
|
||||||||||||||
| methods = methods.Where(m => m.GetParameterTypes().CompareTo(argTypes, exact, considerTypeMatchers: false)); | |
| if (methods.Count() < 2) | |
| methods = methods.Where(m => m.GetParameterTypes().CompareTo(argTypes, exact, considerTypeMatchers: false)).ToList(); | |
| if (methods.Count < 2) |
Copilot
AI
May 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The loop variable type is never used: the predicate always checks DeclaringType == typeof(T). It should use the loop variable type (m.DeclaringType == type) to correctly select the most derived declaring type.
| var method = methods.SingleOrDefault(m => m.DeclaringType == typeof(T)); | |
| var method = methods.SingleOrDefault(m => m.DeclaringType == type); |
Uh oh!
There was an error while loading. Please reload this page.