Skip to content

Commit 7db8996

Browse files
committed
refactor: streamline property injection logic by removing redundant comments
1 parent b3570ad commit 7db8996

1 file changed

Lines changed: 1 addition & 7 deletions

File tree

TUnit.Engine/Services/PropertyInjectionService.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public async Task InjectPropertiesIntoArgumentsAsync(object?[] arguments, Concur
4040
return;
4141
}
4242

43-
// Fast path: check if any arguments need injection
4443
var injectableArgs = arguments
4544
.Where(argument => argument != null && PropertyInjectionCache.HasInjectableProperties(argument.GetType()))
4645
.ToArray();
@@ -50,7 +49,6 @@ public async Task InjectPropertiesIntoArgumentsAsync(object?[] arguments, Concur
5049
return;
5150
}
5251

53-
// Process arguments in parallel
5452
var argumentTasks = injectableArgs
5553
.Select(argument => InjectPropertiesIntoObjectAsync(argument!, objectBag, methodMetadata, events))
5654
.ToArray();
@@ -80,7 +78,6 @@ public Task InjectPropertiesIntoObjectAsync(object instance, ConcurrentDictionar
8078
throw new ArgumentNullException(nameof(events), "TestContextEvents must not be null. Each test permutation must have a unique TestContextEvents instance for proper disposal tracking.");
8179
}
8280

83-
// Start with an empty visited set for cycle detection
8481
#if NETSTANDARD2_0
8582
var visitedObjects = new ConcurrentDictionary<object, byte>();
8683
#else
@@ -96,8 +93,7 @@ internal async Task InjectPropertiesIntoObjectAsyncCore(object instance, Concurr
9693
return;
9794
}
9895

99-
// Prevent cycles - if we're already processing this object, skip it
100-
// TryAdd returns false if the key already exists (thread-safe)
96+
// Prevent cycles
10197
if (!visitedObjects.TryAdd(instance, 0))
10298
{
10399
return;
@@ -117,13 +113,11 @@ await PropertyInjectionCache.GetOrAddInjectionTask(instance, async _ =>
117113
{
118114
var plan = PropertyInjectionCache.GetOrCreatePlan(instance.GetType());
119115

120-
// Use the orchestrator for property initialization
121116
await _orchestrator.InitializeObjectWithPropertiesAsync(
122117
instance, plan, objectBag, methodMetadata, events, visitedObjects);
123118
});
124119
}
125120

126-
// After properties are initialized, recursively inject nested properties
127121
await RecurseIntoNestedPropertiesAsync(instance, objectBag, methodMetadata, events, visitedObjects);
128122
}
129123
catch (Exception ex)

0 commit comments

Comments
 (0)