-
-
Notifications
You must be signed in to change notification settings - Fork 803
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
Expose invocations #627
Expose invocations #627
Conversation
I've created the
Added implementation to
I've made
I performed a Refactor->Rename operation on the property to call it
As mentioned, the property is implemented as |
Hi @Tragedian, nice to hear back from you! I think your PR is in a mergable state as it is. Some feedback:
Looks good to me. I believe you've caught all occurrences of
Looks good to me. Copying
Quick question, is there a reason why you opted not to make A small look ahead: If Moq 5 is going to take much longer than expected, I might clean up the Moq 4 API a little bit. This may encompass, among other things, replacing the |
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.
Sorry, I do have two minor change requests after all:
First, please add an entry to CHANGELOG.md
at the top, like this:
# Moq Changelog
All notable changes to this project will be documented in this file.
The format is loosely based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
+## Unreleased
+
+#### Added
+
+ * Description of the new feature (@informatorius, #627)
+
+
## 4.8.3 (2018-06-09)
Second, if you find the time, it would be nice to have a few unit tests documenting the new feature.
It's the I'm assuming the collection is heavily synchronised internally because there's an expectation it will be modified and read from multiple concurrent executions. On this assumption, the simplest implementation is a copy-on-read model which allows consumers to read their copy of the collection whilst allowing modifications to proceed on the synchronised collection. This is much better to manage for a consumer than an enumerator which is always racing with potential modifications and has to be coded around failing at any moment. It is a sub-optimal implementation of this pattern because it will produce allocations which aren't really needed. There are alternatives we could explore around using a copy-on-write method, or using some form of immutable collection internally (which would significantly help on allocations). It's implemented this way for simplicity, with an eye on potential future improvements without breaking behaviour contracts. |
Agreed, I am not exactly thrilled to have them, either. The reason they are there (for now) is because (IIRC) something like a I just ran a quick experiment with So in summary, I'm convinced. Your implementation will allow us to later get rid of the Thanks for talking me through this. Always good to have one's assumptions challenged. 👍 |
P.S.: Perhaps my look towards |
Merging... thank you! I'll try to release Moq 4.9.0 reasonably quickly; say, in approx. 3 weeks' time. (I'd like to allow some time to gather feedback on possible issues in 4.8.3.) Like I mentioned above, if you have any insights regarding concurrency that you'd like to share here, I'm happy to listen. |
I'd have to ask why you'd want to remove those I do have slight "this-could-be-better" pains with allocating memory every time a read is performed, especially if there's no concurrency in that scenario. I'd need to understand what scenario is most common and optimise for that. If the 99% case is where there is no concurrency, it would be better to not create a copy on every read. If the collection only has to support append and clear functions, using an mutable collection protected by locks and implementing a
The |
If you still want those unit tests, I will try to put together some. |
That would be good, if you find the time. 👍 (I decided to merge your PR without tests anyway because I really wanted to see this through—I've held this back way too long, and it's a fairly straightforward feature after all. :)
I don't have numbers—perhaps we should look at some user projects such as ASP.NET that uses Moq to gather actual data—but I suspect that "no concurrency" is probably the predominant scenario. Perhaps not quite a ≥99% case, though. Yes, |
Tests and collection changes: #628 |
Second take at exposing invocation information.
Invocation information exposed via
IReadOnlyInvocation
interface.Mock invocations exposed via property
IReadOnlyList<IReadOnlyInvocation> Invocations
onMock
class.