fix: create fresh non-shared instances per CombinedDataSources combination by thomhurst · Pull Request #6179 · thomhurst/TUnit (original) (raw)
…ation
[CombinedDataSources] materialized each parameter's data source values once and reused the same object reference across every cartesian combination. For reference values from non-shared sources (e.g. [ClassDataSource] with SharedType.None) this meant one instance was shared across multiple test cases, violating SharedType.None semantics.
Since test registration runs in parallel, both tests would concurrently inject properties into the same instance (the check-resolve-set sequence in PropertyInjector is not atomic), each creating its own nested property value. The losing test then tracked an orphaned object and initialized that at execution, while the test body observed the winner - whose IAsyncInitializer only ran via the other test's initialization. This caused the intermittent AOT failure in CombinedDataSource_WithNestedPropertyInjectionAndMultipleIAsyncInitializers.
Defer value materialization to per-combination factories so each test case invokes the data source row factory itself: non-shared sources get a fresh instance per test case, while shared sources still resolve to their cached shared instance.
Fixes #6177
[](/apps/claude)
CombinedDataSourcesAttribute.GetCartesianProduct and MatrixDataSourceAttribute.GetMatrixValues were byte-for-byte copies of the same odometer-style cartesian product. Extract a single generic helper and use it from both. Also use a using directive instead of a fully-qualified ConcurrentDictionary in the new regression test.
[](/apps/claude)
thomhurst deleted the fix/6177-combined-datasources-fresh-instance-per-combination branch
This was referenced
Jun 8, 2026
This was referenced
Jun 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})