You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix ABI conformance of IMap::Remove, add TryRemove (#655)
* Fix ABI conformance of IMap::Remove, add TryRemove
`single_threaded_map()`'s IMap::Remove did not throw
`hresult_out_of_range` on attempts to remove a nonexistent
key. Now it throws.
Failure to remove a nonexistent key does not invalidate
iterators, because nothing actually changed. This brings
the map implementation in line with the implementations
in other projections.
Note that this is a breaking change. Code that assumed
nonexistent objects could be harmlessly removed will
encounter exceptions when run against C++/WinRT implementations.
This was, however, a pre-existing bug, because implementations
from other projections (C#, C++/CX) always threw under those
conditions.
Added a TryRemove() method for people who wanted the
nonthrowing version.
Note that fixing the ABI conformance is required in order
for TryRemove to work, because TryRemove relies on the
call to Remove failing if the key doesn't exist.
(JavaScript doesn't project objects as maps, so there
is nothing to validate there.)
Tightened the behavior of TryLookup and TryRemove so
they propagate RPC failures. Because the inability to
remove the item could be due to the server being unavailable,
and that's not the same as the item not existing in
the collection. Previous code treated loss of server
the same as "The item doesn't exist", which is not true:
The item could exist, we just were unable to contact
the server to find out.
* TryLookup and TryRemove should not be noexcept
because they can throw on other errors.
Added unit test to verify that errors other than "key not found" are
propagated.
Co-authored-by: Kenny Kerr <[email protected]>
0 commit comments