-
-
Notifications
You must be signed in to change notification settings - Fork 798
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
Strange behavior with dynamic + indexed property #913
Comments
Regarding the first issue (your failing test), it fails because the setup and the invocation don't see the same method: one sees Neither DynamicProxy nor Moq consider the matching DISPIDs at all. (At least for Moq, I suspect we'll keep it that way, at least in the near term, as adding DISPID checks in such a "hot" execution path is going to affect performance for all calls while being beneficial for only a very rare few.) I'll get back to you about the second issue (literal vs. variable). |
I can confirm that with the following revisions, the test passes.
I will need to investigate into ensuring that setups happens for all interfaces with same members to avoid the uncertainty as I don't have any guarantee over which interface will get used. I had a late realization about the literal vs. variable thing. The problem was that the parameter type is an Since that shows that the mistake is with my flawed test, I'll close this issue. Thanks for the help! |
Regarding your second question:
Everything is as it should be in this case. mockDrives.Setup(x => x[It.Is<object>(p => p == input)]).Returns(mockDrive.Object); Break the program after that setup has been made, inspect Now, your matcher uses the These two facts explain why your setup can match for This problem is somewhat academic because this only seems to happen during debugging. It seems that the debugger won't intern strings the same way as would happen if you ran your program regularly, without a debugger attached. I can think of a ways to resolve this:
|
Saw too late you'd already figured out the same thing. :) |
Given this code, using a COM reference to the
Scripting
library (scrrun.dll
, usually located in the..\Windows\System32
folder:The first assert demonstrates that the setups are all good but if we use
dynamic
version, the binding fails. Apparently it returnsnull
at theDrives
, and we cannot go any further.Furthermore, if we execute the following in the immediate window:
Why would the mock behave differently simply because I passed a literal vs. a variable? That doesn't seem right.
The text was updated successfully, but these errors were encountered: