Skip to content

IndexOutOfRangeException when using IContextStore.Set #1908

@arkadiuszwojcik

Description

@arkadiuszwojcik

I get IndexOutOfRangeException while using IContextStore.Set. Looks like a bug in TypedDictionary

bacause:
private static int typeIndex = -1;

when we use Add:

public void Add<TKey>(TValue value)
    {
        lock (_lockObject)
        {
            var id = TypeKey<TKey>.Id;

            if (id >= _values.Length)
            {
                Array.Resize(ref _values, (int)(id * _growthFactor));
            }

            _values[id] = value;
        }
    }

With very first use id becomes 0 and 0 * _growthFactor = 0 so _values[id] = value; fails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions