Skip to content

Dictionary version increment is missing for TrimExcess() and EnsureCapacity() #26784

@danmoseley

Description

@danmoseley

Dictionary<K,V> has a version field that is incremented by modification and tested by enumerators such that any modification of a dictionary during enumeration causes an exception. This is to flag that the enumeration may not lead to self consistent results.

Calls to TrimExcess() and EnsureCapacity() appear to not increment version even though they could modify the backing storage in such a way that they could break enumeration.

They should both have version++.

dotnet/coreclr#18854

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions