Closed
Description
Description
Cannot run concurrent tests using TestServer when using Auto Discovery to register types.
Staetup.cs
services.AddJsonApi(facade => facade.AddCurrentAssembly());
System.InvalidOperationException : Collection was modified; enumeration operation may not execute.
Stack Trace:
at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
at JsonApiDotNetCore.Graph.ServiceDiscoveryFacade.AddAssembly(Assembly assembly) in jsonapidotnetcore\src\JsonApiDotNetCore\Graph\ServiceDiscoveryFacade.cs:line 76
The root cause is due to
private static Dictionary<Assembly, List> _identifiableTypeCache = new Dictionary<Assembly, List>();
which is being concurrently updated by different tests (each starting up its own TestServer for tests isolation).
see:
Environment
- JsonApiDotNetCore Version: 3.1.0
- Other Relevant Package Versions: