-
-
Notifications
You must be signed in to change notification settings - Fork 182
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
Index Safety for List Tranform Operator #762
Index Safety for List Tranform Operator #762
Conversation
This feels kinda like a band-aid, to me. If there's operators that aren't preserving indexes that should be, we should fix them. If there's operators that aren't preserving indexes because they can't, then how is I missed whatever conversation spawned this, what's the usage-scenario here? |
Any stateless operator, or any of the operators myChangeSetObservable.WhereReasonsAreNot(Remove) removes the remove events, and additionally does not maintain state. Therefore when a subsequent Add arrives, the index which the Add carries will be incorrect and could cause an index out of range exception. Thus, the WhereReasonsAre*` actually remove the index. It's a necessary evil which unfortunately have to be handled by other operators. EDIT: Looking at the current implementation, most of the other reasons handle index = -1. However, refresh also does not and should be fixed. Also, I have a thought of a special case which could be optimized: for the case, when it is only refresh which is removed i.e. myChangeSetObservable.WhereReasonsAreNot(Refresh) We could adjust the code to not remove the index. For context, I have used @dwcullop would you be able to address this too? Or if you don't have the time we could to it later? |
Couldn't any of those filtering operators, in theory, track all the indices and issue Even so, I'm still not quite following how a downstream operator can recreate index information, if it was deemed impossible to determine by the upstream operator. |
I will give it a shot. It doesn't seem like too much work. I'll get to it when I can. |
When I was making the List version of If it happened to me, it could happen to anyone, and the library should not throw just by combining valid operators. The other operators, including
I think the issue is reliability of the value. If the operator can't promise that the index will be valid to use later, then it removes it. This signals the downstream operator that it needs to determine the index for itself before performing the operation, which it can do by searching the collection for the value in question. This is not ideal, which is why the indexes are used in the first place, but it works when the indexes are not reliable. Like I said, this is how most of the operators work, this is just closing a gap in the "Replace" scenario of the The important thing to note is that without the fix, 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.
Alas, using SupressRefresh will not work. See my comment.
The Codecov things makes it super annoying to actually follow the changes. |
@glennawatson is there any way to make it less aggressive?. There's a huge number of false messages. |
@ChrisPulman thanks for the commit. Much appreciated |
Yeah, that was a fast turn around. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description
Adds the changes suggested by @RolandPheasant in #744 to avoid throwing an exception when Transform is used in conjunction with other operators such as (
WhereReasonsAre*
) that remove the Index from the Changes.Transform will now check for missing indexes and do a lookup to find the correct index values to use for that situation.
Also adds two unit tests to the Fixture for List Transform. Before the other changes, one test would pass and the other would fail. With the changes, they both pass.