Repository: asynkron/protoactor-dotnet (csharp)

Issue:
IndexOutOfRangeException when using IContextStore.Set
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.

Pull request description:
## Description

Fixes #1908

## Purpose
This pull request is a:

- [x] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)


## Checklist

<!-- Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code. -->

- [x] I have added tests that prove my fix is effective or that my feature works
- [ ] I have added necessary documentation (if appropriate)

Patch:
diff --git a/src/Proto.Actor/Utils/TypedDictionary.cs b/src/Proto.Actor/Utils/TypedDictionary.cs
index b7c8b6d6e0..07df7dce6c 100644
--- a/src/Proto.Actor/Utils/TypedDictionary.cs
+++ b/src/Proto.Actor/Utils/TypedDictionary.cs
@@ -35,7 +35,7 @@ public void Add<TKey>(TValue value)
 
             if (id >= _values.Length)
             {
-                Array.Resize(ref _values, (int)(id * _growthFactor));
+                Array.Resize(ref _values, (int)((id + 1) * _growthFactor));
             }
 
             _values[id] = value;


Test patch:
diff --git a/tests/Proto.Actor.Tests/StoreTests.cs b/tests/Proto.Actor.Tests/StoreTests.cs
new file mode 100644
index 0000000000..4e062d1f3d
--- /dev/null
+++ b/tests/Proto.Actor.Tests/StoreTests.cs
@@ -0,0 +1,24 @@
+﻿using System.Threading.Tasks;
+using Xunit;
+
+namespace Proto.Tests;
+
+public class StoreTests
+{
+    [Fact]
+    public async Task Given_RootContextStore_SetAndGetCustomObject()
+    {
+        await using var system = new ActorSystem();
+        var context = system.Root;
+
+        var toStore = new StoreType();
+        context.Set(toStore);
+        var fromStore = context.Get<StoreType>();
+
+        Assert.Same(toStore, fromStore);
+    }
+
+    class StoreType
+    {
+    }
+}
\ No newline at end of file