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
8 changes: 3 additions & 5 deletions TUnit.Core/ContextProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,11 @@ public class ContextProvider(IServiceProvider serviceProvider, string testSessio
/// </summary>
public AssemblyHookContext GetOrCreateAssemblyContext(Assembly assembly)
{
return _assemblyContexts.GetOrAdd(assembly, asm =>
{
return new AssemblyHookContext(TestSessionContext)
return _assemblyContexts.GetOrAdd(assembly, static (assembly, context) =>
new AssemblyHookContext(context)
{
Assembly = assembly
};
});
}, TestSessionContext);
}

/// <summary>
Expand Down
5 changes: 3 additions & 2 deletions TUnit.Core/ObjectInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ private static async ValueTask InitializeCoreAsync(
// is called exactly once, even under contention. GetOrAdd's factory may be
// called multiple times, but Lazy ensures only one initialization runs.
var lazyTask = InitializationTasks.GetOrAdd(obj,
_ => new Lazy<Task>(
static (_, asyncInitializer) => new Lazy<Task>(
asyncInitializer.InitializeAsync,
LazyThreadSafetyMode.ExecutionAndPublication));
LazyThreadSafetyMode.ExecutionAndPublication)
, asyncInitializer);

try
{
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Core/TestContext.StateBag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public partial class TestContext
/// <inheritdoc/>
T ITestStateBag.GetOrAdd<T>(string key, Func<string, T> valueFactory)
{
var value = ObjectBag.GetOrAdd(key, k => valueFactory(k)!);
var value = ObjectBag.GetOrAdd(key, static (k, valueFactory) => valueFactory(k)!, valueFactory);

if (value is T typedValue)
{
Expand Down
Loading