-
-
Notifications
You must be signed in to change notification settings - Fork 794
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
Support for Mock.Of<T> with not default constructor #963
Comments
Any new about this? |
@JorTurFer, I'd like to apologize to you for the radio silence. I've seen your issue and the PR, but haven't got around to dealing with it (and other issues)... see #966 for the reason why. Sorry again for the delay. |
@stakx dont worry !! I wrote a comment to do ping, but you should enjoy the vacation. It's mandatory !! The repository will be here when you come back and the world will continue xD. |
Hi @stakx , any new about this? |
I looked into the pull and did a review just to support this addition @JorTurFer since it is good work! Hopefully you agree with my reviewcomments @stakx |
@JorTurFer once again sorry for the long silence. I've prioritized some other work and have been busy over at the DynamicProxy repo so we'll eventually get a full @peterdew, thanks for jumping in and doing a code review. I agree that it looks like a solid & well done PR. My (perhaps somewhat unreasonable?) gripe is with Moq's public API is chock-full with method overloads, and we keep adding more all the time. This is mostly fine but care needs to be taken in those cases to not break existing code by making existing code suddenly wind up with a different overload when compiling after a Moq update. A single It is this last bit I am worried about: can we prove somehow that existing code won't suddenly end up in the new method when it called a different one before? Second, I think the new feature should be rephrased slightly because "non-generic constructor" suggests something that doesn't exist: ctors are never generic; it's really the generic class Finally, and perhaps that's the most fundamental question I'm asking myself here: does this addition actually add value? Why do we need two separate APIs for creating mocks? Remember that I'm undecided on many of these points and regarding the overload resolution would need to take a closer look; I just thought I'd let you know my thoughts. |
Thanks for share your thoughts @stakx. |
@JorTurFer, to be clear, IIRC Moq v5 is gravitating more towards something like I'm willing to merge your PR despite my misgivings about the API redundancy, BUT I still think we need to be somewhat more systematic about the overload issue; I think we shouldn't just hope for the best, but instead try to identify some scenarios/instances where the new overload could be problematic (if any exist, that is). |
Sorry @stakx , when I said deprecate I wanted to say mark as obsolete (I don't know what I was thinking about...). My experience said that it is not a problem but you are right about the overloads' posible danger. |
Closing this as "unresolved", the accompanying PR has since been closed, and this enhancement does not have priority at this time. |
At the moment, new Mock and Mock.Of are similar but if you need use non generic constructor you must use new Mock. If you are using the Mock.Of syntax in the project, change all for this will be a problem.
Add support for this is a very little change and give more functionality to the Mock.Of syntax.
The text was updated successfully, but these errors were encountered: