Skip to content
This repository was archived by the owner on Nov 27, 2018. It is now read-only.

Conversation

@drieseng
Copy link
Contributor

@drieseng drieseng commented Oct 14, 2018

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.

return false;
}

EnsureCapacity(Count);
Copy link
Member

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.

Copy link
Contributor Author

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)
Copy link
Member

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?

Copy link
Contributor Author

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);
}

Copy link
Member

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

Copy link
Contributor Author

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.
Copy link
Member

@rynowak rynowak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thanks

@rynowak rynowak merged commit 5c31f1f into aspnet:release/2.2 Oct 17, 2018
rynowak added a commit to aspnet/HttpAbstractions that referenced this pull request Oct 17, 2018
rynowak added a commit to aspnet/HttpAbstractions that referenced this pull request Oct 17, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants