Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions TUnit.Core/ContextProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,20 @@ public AssemblyHookContext GetOrCreateAssemblyContext(Assembly assembly)
/// <summary>
/// Gets or creates a class context
/// </summary>
[UnconditionalSuppressMessage("Trimming", "IL2111",
Justification = "Type parameter is annotated at the method boundary.")]
public ClassHookContext GetOrCreateClassContext(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicMethods)]
Type classType)
{
return _classContexts.GetOrAdd(classType, type =>
return _classContexts.GetOrAdd(classType, static ([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicMethods)]
type, state) =>
{
return new ClassHookContext(GetOrCreateAssemblyContext(classType.Assembly))
return new ClassHookContext(state.GetOrCreateAssemblyContext(type.Assembly))
{
ClassType = classType
ClassType = type
};
});
}, this);
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions TUnit.Engine/Discovery/ReflectionTestDataCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,15 @@ public async IAsyncEnumerable<TestMetadata> CollectTestsStreamingAsync(
// Stream tests from this assembly
await foreach (var test in DiscoverTestsInAssemblyStreamingAsync(assembly, cancellationToken))
{
ImmutableInterlocked.Update(ref _discoveredTests, list => list.Add(test));
ImmutableInterlocked.Update(ref _discoveredTests, static (list, test) => list.Add(test), test);
yield return test;
}
}

// Stream dynamic tests
await foreach (var dynamicTest in DiscoverDynamicTestsStreamingAsync(testSessionId, cancellationToken))
{
ImmutableInterlocked.Update(ref _discoveredTests, list => list.Add(dynamicTest));
ImmutableInterlocked.Update(ref _discoveredTests, static (list, dynamicTest) => list.Add(dynamicTest), dynamicTest);
yield return dynamicTest;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ namespace
public .TestSessionContext TestSessionContext { get; }
public .TestContext CreateTestContext(string testName, [.(..None | ..PublicParameterlessConstructor | ..PublicConstructors | ..PublicMethods | ..PublicProperties)] classType, .TestBuilderContext testBuilderContext, .CancellationToken cancellationToken) { }
public .AssemblyHookContext GetOrCreateAssemblyContext(.Assembly assembly) { }
[.("Trimming", "IL2111", Justification="Type parameter is annotated at the method boundary.")]
public .ClassHookContext GetOrCreateClassContext([.(..None | ..PublicParameterlessConstructor | ..PublicConstructors | ..PublicMethods | ..PublicProperties)] classType) { }
}
public class CultureExecutor : .DedicatedThreadExecutor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ namespace
public .TestSessionContext TestSessionContext { get; }
public .TestContext CreateTestContext(string testName, [.(..None | ..PublicParameterlessConstructor | ..PublicConstructors | ..PublicMethods | ..PublicProperties)] classType, .TestBuilderContext testBuilderContext, .CancellationToken cancellationToken) { }
public .AssemblyHookContext GetOrCreateAssemblyContext(.Assembly assembly) { }
[.("Trimming", "IL2111", Justification="Type parameter is annotated at the method boundary.")]
public .ClassHookContext GetOrCreateClassContext([.(..None | ..PublicParameterlessConstructor | ..PublicConstructors | ..PublicMethods | ..PublicProperties)] classType) { }
}
public class CultureExecutor : .DedicatedThreadExecutor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ namespace
public .TestSessionContext TestSessionContext { get; }
public .TestContext CreateTestContext(string testName, [.(..None | ..PublicParameterlessConstructor | ..PublicConstructors | ..PublicMethods | ..PublicProperties)] classType, .TestBuilderContext testBuilderContext, .CancellationToken cancellationToken) { }
public .AssemblyHookContext GetOrCreateAssemblyContext(.Assembly assembly) { }
[.("Trimming", "IL2111", Justification="Type parameter is annotated at the method boundary.")]
public .ClassHookContext GetOrCreateClassContext([.(..None | ..PublicParameterlessConstructor | ..PublicConstructors | ..PublicMethods | ..PublicProperties)] classType) { }
}
public class CultureExecutor : .DedicatedThreadExecutor
Expand Down
Loading