Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
024a2ca
feat: implement IAsyncDiscoveryInitializer and related classes for im…
thomhurst Dec 7, 2025
7cdc0fc
feat: implement IAsyncDiscoveryInitializer and related classes for im…
thomhurst Dec 7, 2025
bebb3e2
feat: implement IAsyncDiscoveryInitializer and related classes for im…
thomhurst Dec 7, 2025
0041ee5
feat: implement IAsyncDiscoveryInitializer and related classes for im…
thomhurst Dec 7, 2025
8e97f35
feat: implement IAsyncDiscoveryInitializer and related classes for im…
thomhurst Dec 7, 2025
07b2215
feat: implement IAsyncDiscoveryInitializer and related classes for im…
thomhurst Dec 7, 2025
8589baa
feat: implement IAsyncDiscoveryInitializer and related classes for im…
thomhurst Dec 7, 2025
5c78262
feat: implement IAsyncDiscoveryInitializer and related classes for im…
thomhurst Dec 7, 2025
579cd75
feat: implement IAsyncDiscoveryInitializer and related classes for im…
thomhurst Dec 7, 2025
8c661b3
feat: implement IAsyncDiscoveryInitializer and related classes for im…
thomhurst Dec 7, 2025
8030e42
feat: implement IAsyncDiscoveryInitializer and related classes for im…
thomhurst Dec 7, 2025
1646680
feat: enhance type handling and object tracking with custom primitive…
thomhurst Dec 7, 2025
851e21c
feat: improve disposal callback registration logic to handle untracke…
thomhurst Dec 7, 2025
f89adb8
feat: change visibility of object graph related classes and interface…
thomhurst Dec 7, 2025
a1938e3
feat: implement IAsyncDiscoveryInitializer and related classes for im…
thomhurst Dec 7, 2025
9efbd55
feat: skip PlaceholderInstance during data source class resolution fo…
thomhurst Dec 7, 2025
da86e46
fix: normalize line endings in exception message assertions for consi…
thomhurst Dec 7, 2025
ca3065f
fix: normalize line endings in exception messages for consistency acr…
thomhurst Dec 7, 2025
2799dd7
fix: remove premature cache removal for shared data sources
thomhurst Dec 7, 2025
ff2e57e
feat: enable parallel initialization of tracked objects during test e…
thomhurst Dec 7, 2025
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
Prev Previous commit
Next Next commit
feat: change visibility of object graph related classes and interface…
…s to internal for encapsulation
  • Loading branch information
thomhurst committed Dec 7, 2025
commit f89adb836a1c980ab2c8d052acf64261ccf1eb13
2 changes: 1 addition & 1 deletion TUnit.Core/Discovery/ObjectGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace TUnit.Core.Discovery;
/// to prevent callers from corrupting internal state.
/// Uses Lazy<T> for thread-safe lazy initialization of read-only views.
/// </remarks>
public sealed class ObjectGraph : IObjectGraph
internal sealed class ObjectGraph : IObjectGraph
{
private readonly ConcurrentDictionary<int, HashSet<object>> _objectsByDepth;
private readonly HashSet<object> _allObjects;
Expand Down
4 changes: 2 additions & 2 deletions TUnit.Core/Discovery/ObjectGraphDiscoverer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace TUnit.Core.Discovery;
/// <param name="PropertyName">The name of the property that failed to access.</param>
/// <param name="ErrorMessage">The error message.</param>
/// <param name="Exception">The exception that occurred.</param>
public readonly record struct DiscoveryError(string TypeName, string PropertyName, string ErrorMessage, Exception Exception);
internal readonly record struct DiscoveryError(string TypeName, string PropertyName, string ErrorMessage, Exception Exception);

/// <summary>
/// Centralized service for discovering and organizing object graphs.
Expand All @@ -37,7 +37,7 @@ namespace TUnit.Core.Discovery;
/// rather than thrown, allowing discovery to continue despite individual property failures.
/// </para>
/// </remarks>
public sealed class ObjectGraphDiscoverer : IObjectGraphTracker
internal sealed class ObjectGraphDiscoverer : IObjectGraphTracker
{
/// <summary>
/// Maximum recursion depth for object graph discovery.
Expand Down
6 changes: 3 additions & 3 deletions TUnit.Core/Interfaces/IObjectGraphDiscoverer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace TUnit.Core.Interfaces;
/// For tracking operations that modify TestContext.TrackedObjects, see <see cref="IObjectGraphTracker"/>.
/// </para>
/// </remarks>
public interface IObjectGraphDiscoverer
internal interface IObjectGraphDiscoverer
{
/// <summary>
/// Discovers all objects from a test context, organized by depth level.
Expand Down Expand Up @@ -81,7 +81,7 @@ public interface IObjectGraphDiscoverer
/// The distinction exists for semantic clarity and future extensibility.
/// </para>
/// </remarks>
public interface IObjectGraphTracker : IObjectGraphDiscoverer
internal interface IObjectGraphTracker : IObjectGraphDiscoverer
{
// All methods inherited from IObjectGraphDiscoverer
// This interface provides semantic clarity for tracking operations
Expand All @@ -94,7 +94,7 @@ public interface IObjectGraphTracker : IObjectGraphDiscoverer
/// Collections are exposed as read-only to prevent callers from corrupting internal state.
/// Use <see cref="GetObjectsAtDepth"/> and <see cref="GetDepthsDescending"/> for safe iteration.
/// </remarks>
public interface IObjectGraph
internal interface IObjectGraph
{
/// <summary>
/// Gets objects organized by depth (0 = root arguments, 1+ = nested).
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Core/Interfaces/IObjectInitializationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace TUnit.Core.Interfaces;
/// </list>
/// </para>
/// </remarks>
public interface IObjectInitializationService
internal interface IObjectInitializationService
{
/// <summary>
/// Initializes an object during the execution phase.
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Core/Services/ObjectInitializationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace TUnit.Core.Services;
/// behavior and avoid duplicate caches. This consolidates initialization tracking in one place.
/// </para>
/// </remarks>
public sealed class ObjectInitializationService : IObjectInitializationService
internal sealed class ObjectInitializationService : IObjectInitializationService
{
/// <summary>
/// Creates a new instance of the initialization service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1664,36 +1664,6 @@ namespace .DataSources
public static string FormatArguments(object?[] arguments, .<<object?, string?>> formatters) { }
}
}
namespace .Discovery
{
public readonly struct DiscoveryError : <.>
{
public DiscoveryError(string TypeName, string PropertyName, string ErrorMessage, Exception) { }
public string ErrorMessage { get; init; }
public Exception { get; init; }
public string PropertyName { get; init; }
public string TypeName { get; init; }
}
public sealed class ObjectGraph : .
{
public ObjectGraph(.<int, .<object>> objectsByDepth, .<object> allObjects) { }
public .<object> AllObjects { get; }
public int MaxDepth { get; }
public .<int, .<object>> ObjectsByDepth { get; }
public .<int> GetDepthsDescending() { }
public .<object> GetObjectsAtDepth(int depth) { }
}
public sealed class ObjectGraphDiscoverer : ., .
{
public ObjectGraphDiscoverer() { }
public .<int, .<object>> DiscoverAndTrackObjects(.TestContext testContext, .CancellationToken cancellationToken = default) { }
public . DiscoverNestedObjectGraph(object rootObject, .CancellationToken cancellationToken = default) { }
public . DiscoverObjectGraph(.TestContext testContext, .CancellationToken cancellationToken = default) { }
public static void ClearCache() { }
public static void ClearDiscoveryErrors() { }
public static .<.> GetDiscoveryErrors() { }
}
}
namespace .Enums
{
public enum DataGeneratorType
Expand Down Expand Up @@ -2328,28 +2298,6 @@ namespace .Interfaces
{
. OnLastTestInTestSession(.TestSessionContext current, .TestContext testContext);
}
public interface IObjectGraph
{
.<object> AllObjects { get; }
int MaxDepth { get; }
.<int, .<object>> ObjectsByDepth { get; }
.<int> GetDepthsDescending();
.<object> GetObjectsAtDepth(int depth);
}
public interface IObjectGraphDiscoverer
{
.<int, .<object>> DiscoverAndTrackObjects(.TestContext testContext, .CancellationToken cancellationToken = default);
. DiscoverNestedObjectGraph(object rootObject, .CancellationToken cancellationToken = default);
. DiscoverObjectGraph(.TestContext testContext, .CancellationToken cancellationToken = default);
}
public interface IObjectGraphTracker : . { }
public interface IObjectInitializationService
{
void ClearCache();
. InitializeAsync(object? obj, .CancellationToken cancellationToken = default);
. InitializeForDiscoveryAsync(object? obj, .CancellationToken cancellationToken = default);
bool IsInitialized(object? obj);
}
public interface IParallelConstraint { }
public interface IParallelLimit
{
Expand Down Expand Up @@ -2685,14 +2633,6 @@ namespace .Services
public [] ResolveGenericClassArguments([.(..PublicConstructors)] genericTypeDefinition, object?[] constructorArguments) { }
public [] ResolveGenericMethodArguments(.MethodInfo genericMethodDefinition, object?[] runtimeArguments) { }
}
public sealed class ObjectInitializationService : .
{
public ObjectInitializationService() { }
public void ClearCache() { }
public . InitializeAsync(object? obj, .CancellationToken cancellationToken = default) { }
public . InitializeForDiscoveryAsync(object? obj, .CancellationToken cancellationToken = default) { }
public bool IsInitialized(object? obj) { }
}
public static class ServiceProviderExtensions
{
public static object GetRequiredService(this serviceProvider, serviceType) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1664,36 +1664,6 @@ namespace .DataSources
public static string FormatArguments(object?[] arguments, .<<object?, string?>> formatters) { }
}
}
namespace .Discovery
{
public readonly struct DiscoveryError : <.>
{
public DiscoveryError(string TypeName, string PropertyName, string ErrorMessage, Exception) { }
public string ErrorMessage { get; init; }
public Exception { get; init; }
public string PropertyName { get; init; }
public string TypeName { get; init; }
}
public sealed class ObjectGraph : .
{
public ObjectGraph(.<int, .<object>> objectsByDepth, .<object> allObjects) { }
public .<object> AllObjects { get; }
public int MaxDepth { get; }
public .<int, .<object>> ObjectsByDepth { get; }
public .<int> GetDepthsDescending() { }
public .<object> GetObjectsAtDepth(int depth) { }
}
public sealed class ObjectGraphDiscoverer : ., .
{
public ObjectGraphDiscoverer() { }
public .<int, .<object>> DiscoverAndTrackObjects(.TestContext testContext, .CancellationToken cancellationToken = default) { }
public . DiscoverNestedObjectGraph(object rootObject, .CancellationToken cancellationToken = default) { }
public . DiscoverObjectGraph(.TestContext testContext, .CancellationToken cancellationToken = default) { }
public static void ClearCache() { }
public static void ClearDiscoveryErrors() { }
public static .<.> GetDiscoveryErrors() { }
}
}
namespace .Enums
{
public enum DataGeneratorType
Expand Down Expand Up @@ -2328,28 +2298,6 @@ namespace .Interfaces
{
. OnLastTestInTestSession(.TestSessionContext current, .TestContext testContext);
}
public interface IObjectGraph
{
.<object> AllObjects { get; }
int MaxDepth { get; }
.<int, .<object>> ObjectsByDepth { get; }
.<int> GetDepthsDescending();
.<object> GetObjectsAtDepth(int depth);
}
public interface IObjectGraphDiscoverer
{
.<int, .<object>> DiscoverAndTrackObjects(.TestContext testContext, .CancellationToken cancellationToken = default);
. DiscoverNestedObjectGraph(object rootObject, .CancellationToken cancellationToken = default);
. DiscoverObjectGraph(.TestContext testContext, .CancellationToken cancellationToken = default);
}
public interface IObjectGraphTracker : . { }
public interface IObjectInitializationService
{
void ClearCache();
. InitializeAsync(object? obj, .CancellationToken cancellationToken = default);
. InitializeForDiscoveryAsync(object? obj, .CancellationToken cancellationToken = default);
bool IsInitialized(object? obj);
}
public interface IParallelConstraint { }
public interface IParallelLimit
{
Expand Down Expand Up @@ -2685,14 +2633,6 @@ namespace .Services
public [] ResolveGenericClassArguments([.(..PublicConstructors)] genericTypeDefinition, object?[] constructorArguments) { }
public [] ResolveGenericMethodArguments(.MethodInfo genericMethodDefinition, object?[] runtimeArguments) { }
}
public sealed class ObjectInitializationService : .
{
public ObjectInitializationService() { }
public void ClearCache() { }
public . InitializeAsync(object? obj, .CancellationToken cancellationToken = default) { }
public . InitializeForDiscoveryAsync(object? obj, .CancellationToken cancellationToken = default) { }
public bool IsInitialized(object? obj) { }
}
public static class ServiceProviderExtensions
{
public static object GetRequiredService(this serviceProvider, serviceType) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1664,36 +1664,6 @@ namespace .DataSources
public static string FormatArguments(object?[] arguments, .<<object?, string?>> formatters) { }
}
}
namespace .Discovery
{
public readonly struct DiscoveryError : <.>
{
public DiscoveryError(string TypeName, string PropertyName, string ErrorMessage, Exception) { }
public string ErrorMessage { get; init; }
public Exception { get; init; }
public string PropertyName { get; init; }
public string TypeName { get; init; }
}
public sealed class ObjectGraph : .
{
public ObjectGraph(.<int, .<object>> objectsByDepth, .<object> allObjects) { }
public .<object> AllObjects { get; }
public int MaxDepth { get; }
public .<int, .<object>> ObjectsByDepth { get; }
public .<int> GetDepthsDescending() { }
public .<object> GetObjectsAtDepth(int depth) { }
}
public sealed class ObjectGraphDiscoverer : ., .
{
public ObjectGraphDiscoverer() { }
public .<int, .<object>> DiscoverAndTrackObjects(.TestContext testContext, .CancellationToken cancellationToken = default) { }
public . DiscoverNestedObjectGraph(object rootObject, .CancellationToken cancellationToken = default) { }
public . DiscoverObjectGraph(.TestContext testContext, .CancellationToken cancellationToken = default) { }
public static void ClearCache() { }
public static void ClearDiscoveryErrors() { }
public static .<.> GetDiscoveryErrors() { }
}
}
namespace .Enums
{
public enum DataGeneratorType
Expand Down Expand Up @@ -2328,28 +2298,6 @@ namespace .Interfaces
{
. OnLastTestInTestSession(.TestSessionContext current, .TestContext testContext);
}
public interface IObjectGraph
{
.<object> AllObjects { get; }
int MaxDepth { get; }
.<int, .<object>> ObjectsByDepth { get; }
.<int> GetDepthsDescending();
.<object> GetObjectsAtDepth(int depth);
}
public interface IObjectGraphDiscoverer
{
.<int, .<object>> DiscoverAndTrackObjects(.TestContext testContext, .CancellationToken cancellationToken = default);
. DiscoverNestedObjectGraph(object rootObject, .CancellationToken cancellationToken = default);
. DiscoverObjectGraph(.TestContext testContext, .CancellationToken cancellationToken = default);
}
public interface IObjectGraphTracker : . { }
public interface IObjectInitializationService
{
void ClearCache();
. InitializeAsync(object? obj, .CancellationToken cancellationToken = default);
. InitializeForDiscoveryAsync(object? obj, .CancellationToken cancellationToken = default);
bool IsInitialized(object? obj);
}
public interface IParallelConstraint { }
public interface IParallelLimit
{
Expand Down Expand Up @@ -2685,14 +2633,6 @@ namespace .Services
public [] ResolveGenericClassArguments([.(..PublicConstructors)] genericTypeDefinition, object?[] constructorArguments) { }
public [] ResolveGenericMethodArguments(.MethodInfo genericMethodDefinition, object?[] runtimeArguments) { }
}
public sealed class ObjectInitializationService : .
{
public ObjectInitializationService() { }
public void ClearCache() { }
public . InitializeAsync(object? obj, .CancellationToken cancellationToken = default) { }
public . InitializeForDiscoveryAsync(object? obj, .CancellationToken cancellationToken = default) { }
public bool IsInitialized(object? obj) { }
}
public static class ServiceProviderExtensions
{
public static object GetRequiredService(this serviceProvider, serviceType) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1617,36 +1617,6 @@ namespace .DataSources
public static string FormatArguments(object?[] arguments, .<<object?, string?>> formatters) { }
}
}
namespace .Discovery
{
public readonly struct DiscoveryError : <.>
{
public DiscoveryError(string TypeName, string PropertyName, string ErrorMessage, Exception) { }
public string ErrorMessage { get; init; }
public Exception { get; init; }
public string PropertyName { get; init; }
public string TypeName { get; init; }
}
public sealed class ObjectGraph : .
{
public ObjectGraph(.<int, .<object>> objectsByDepth, .<object> allObjects) { }
public .<object> AllObjects { get; }
public int MaxDepth { get; }
public .<int, .<object>> ObjectsByDepth { get; }
public .<int> GetDepthsDescending() { }
public .<object> GetObjectsAtDepth(int depth) { }
}
public sealed class ObjectGraphDiscoverer : ., .
{
public ObjectGraphDiscoverer() { }
public .<int, .<object>> DiscoverAndTrackObjects(.TestContext testContext, .CancellationToken cancellationToken = default) { }
public . DiscoverNestedObjectGraph(object rootObject, .CancellationToken cancellationToken = default) { }
public . DiscoverObjectGraph(.TestContext testContext, .CancellationToken cancellationToken = default) { }
public static void ClearCache() { }
public static void ClearDiscoveryErrors() { }
public static .<.> GetDiscoveryErrors() { }
}
}
namespace .Enums
{
public enum DataGeneratorType
Expand Down Expand Up @@ -2260,28 +2230,6 @@ namespace .Interfaces
{
. OnLastTestInTestSession(.TestSessionContext current, .TestContext testContext);
}
public interface IObjectGraph
{
.<object> AllObjects { get; }
int MaxDepth { get; }
.<int, .<object>> ObjectsByDepth { get; }
.<int> GetDepthsDescending();
.<object> GetObjectsAtDepth(int depth);
}
public interface IObjectGraphDiscoverer
{
.<int, .<object>> DiscoverAndTrackObjects(.TestContext testContext, .CancellationToken cancellationToken = default);
. DiscoverNestedObjectGraph(object rootObject, .CancellationToken cancellationToken = default);
. DiscoverObjectGraph(.TestContext testContext, .CancellationToken cancellationToken = default);
}
public interface IObjectGraphTracker : . { }
public interface IObjectInitializationService
{
void ClearCache();
. InitializeAsync(object? obj, .CancellationToken cancellationToken = default);
. InitializeForDiscoveryAsync(object? obj, .CancellationToken cancellationToken = default);
bool IsInitialized(object? obj);
}
public interface IParallelConstraint { }
public interface IParallelLimit
{
Expand Down Expand Up @@ -2606,14 +2554,6 @@ namespace .Services
public [] ResolveGenericClassArguments( genericTypeDefinition, object?[] constructorArguments) { }
public [] ResolveGenericMethodArguments(.MethodInfo genericMethodDefinition, object?[] runtimeArguments) { }
}
public sealed class ObjectInitializationService : .
{
public ObjectInitializationService() { }
public void ClearCache() { }
public . InitializeAsync(object? obj, .CancellationToken cancellationToken = default) { }
public . InitializeForDiscoveryAsync(object? obj, .CancellationToken cancellationToken = default) { }
public bool IsInitialized(object? obj) { }
}
public static class ServiceProviderExtensions
{
public static object GetRequiredService(this serviceProvider, serviceType) { }
Expand Down
Loading