Skip to content

Commit 4f23176

Browse files
Add detailed debug logging to diagnose query issue
- Log before/after Init in test to verify entity state - Log detailed GroupResultEnumerator constructor flow - Check Components array state and bitIdx values - Verify archetype matching count This will identify why GroupOf finds 0 entities in CI but 1 locally.
1 parent 1ed2abf commit 4f23176

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

EasyEcs.Core/Enumerators/GroupResultEnumerator.1.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@ public GroupResultEnumerator(Context context)
3333
_entityIndexInArchetype = 0;
3434
Current = default;
3535

36+
Console.WriteLine($"GroupResultEnumerator<{typeof(T).Name}>: Starting query");
37+
3638
if (context.TagRegistry.TryGetTagBitIndex<T>(out var bitIdx))
3739
{
40+
Console.WriteLine($"GroupResultEnumerator<{typeof(T).Name}>: Found bitIdx = {bitIdx}");
41+
3842
// Safely access Components array (may not be initialized yet)
3943
if (context.Components != null && bitIdx < context.Components.Length)
4044
{
@@ -46,8 +50,17 @@ public GroupResultEnumerator(Context context)
4650

4751
// Get matching archetypes from cache (O(1) after first access)
4852
_matchingArchetypes = context.GetMatchingArchetypes(queryTag);
53+
Console.WriteLine($"GroupResultEnumerator<{typeof(T).Name}>: Found {_matchingArchetypes.Count} matching archetypes");
54+
}
55+
else
56+
{
57+
Console.WriteLine($"GroupResultEnumerator<{typeof(T).Name}>: Components is null or bitIdx out of range. Components != null: {context.Components != null}, Components.Length: {context.Components?.Length ?? -1}, bitIdx: {bitIdx}");
4958
}
5059
}
60+
else
61+
{
62+
Console.WriteLine($"GroupResultEnumerator<{typeof(T).Name}>: TryGetTagBitIndex returned false");
63+
}
5164
}
5265

5366
public GroupResultEnumerator<T> GetEnumerator() => this;

EasyEcs.UnitTest/SimpleTest.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,20 @@ public async Task TrivialTest()
3030

3131
// Add components to the entity (immediate execution - no callbacks!)
3232
entity.AddComponent<SizeComponent>();
33-
entity.AddComponent<ScaleComponent>(); // ResizeSystem will set factor to 2 in its OnInit
33+
var scaleCompRef = entity.AddComponent<ScaleComponent>(); // ResizeSystem will set factor to 2 in its OnInit
34+
35+
Console.WriteLine($"Before Init: Entity {entity.Id} has ScaleComponent: {entity.HasComponent<ScaleComponent>()}");
36+
Console.WriteLine($"Before Init: ScaleComponent.Factor = {scaleCompRef.Value.Factor}");
3437

3538
// Start the context, automatically initializing all systems,
3639
// then when it is out of scope, it will dispose the context
3740
await using (await ctx.Init())
3841
{
3942
var entityById = ctx.GetEntityById(0);
4043

44+
Console.WriteLine($"After Init: Entity {entityById.Value.Id} has ScaleComponent: {entityById.Value.HasComponent<ScaleComponent>()}");
45+
Console.WriteLine($"After Init: ScaleComponent.Factor = {entityById.Value.GetComponent<ScaleComponent>().Value.Factor}");
46+
4147
// Check if factor is 2, implying ResizeSystem has set it in its OnInit
4248
Assert.That(entityById.Value.GetComponent<ScaleComponent>().Value.Factor, Is.EqualTo(2));
4349

0 commit comments

Comments
 (0)