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
3.13.3 Regression - CollectionTally correctly handles ImmutableDictionary again #4097
3.13.3 Regression - CollectionTally correctly handles ImmutableDictionary again #4097
Conversation
@@ -170,10 +170,8 @@ void TryRemoveSlow(IEnumerable c) | |||
|
|||
private static ArrayList ToArrayList(IEnumerable items) | |||
{ | |||
if (items is ICollection ic) | |||
return new ArrayList(ic); | |||
var list = items is ICollection ic ? new ArrayList(ic.Count) : new ArrayList(); |
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.
ImmutableDictionary.CopyTo
will convert the underlying type which is why the ctor which took in an ICollection was failing, but we can at least initialize the ArrayList to the proper size if it is known
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.
LGTM
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.
LGTM.
Cherrypick PR #4097 onto main
Fixes #4095
Allows CollectionTally to work with ImmutableDictionary properly again by avoiding a bulk-add for the ICollection case