Skip to content

OrderedDictionary.SetAt bug #103637

@eiriktsarpalis

Description

@eiriktsarpalis

I encountered the following issue while adapting the new generic OrderedDictionary to STJ's JsonObject type:

[Fact]
public static void OrderedDictionary_SetAt_Bug()
{
    var dict = new OrderedDictionary<int, int>
    {
        [0] = 0
    };

    dict.SetAt(index: 0, key: 42, value: 42);

    Assert.Equal(1, dict.Count);
    Assert.Equal([new(42, 42)], dict);
    Assert.False(dict.ContainsKey(0));
    Assert.True(dict.ContainsKey(42)); // Fails
}

Metadata

Metadata

Assignees

Labels

area-System.Collectionsbugin-prThere is an active PR which will close this issue when it is merged

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions