-
Notifications
You must be signed in to change notification settings - Fork 123
Add Remove(string key, out object value) overload to RouteValueDictionary #858
Conversation
| return false; | ||
| } | ||
|
|
||
| EnsureCapacity(Count); |
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.
Add a comment that this is called for the side-effect.
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.
Done.
| ThrowArgumentNullExceptionForKey(); | ||
| } | ||
|
|
||
| if (Count == 0) |
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.
nit: there's lots of mixing of Count and _count here. Does it make sense to use a local and update at the end?
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.
I updated the new Remove overload to consistently use the _count field.
Note that there's a mix throughout this class.
| Assert.Empty(dict); | ||
| Assert.IsType<KeyValuePair<string, object>[]>(dict._arrayStorage); | ||
| } | ||
|
|
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.
For array storage I'd also like to see tests for the case where the value removed is the first/middle/last
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.
Done
…rloads. Added comment on EnsureCapacity call. Added test for removing first/middle/last entry.
rynowak
left a comment
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.
Great! Thanks
Adds a
Remove(string key, out object value)overload to RouteValueDictionary, and use it where applicable.Note that we could also benefit from using the same overload on Dictionary<TKey, TValue> in other places. Unless we use conditional compilation, we cannot use this overload since it's not available in .NET Standard 2.0.