diff --git a/TUnit.Core/SharedDataSources.cs b/TUnit.Core/SharedDataSources.cs
new file mode 100644
index 0000000000..27ec9236da
--- /dev/null
+++ b/TUnit.Core/SharedDataSources.cs
@@ -0,0 +1,216 @@
+using System.Diagnostics.CodeAnalysis;
+using TUnit.Core.Helpers;
+
+namespace TUnit.Core;
+
+///
+/// Provides shared instance management for custom data sources.
+/// Use this class to implement custom data source attributes that need the same
+/// sharing behavior as .
+///
+public static class SharedDataSources
+{
+ ///
+ /// Gets or creates a shared instance based on the specified sharing type, using the default constructor.
+ ///
+ /// The type of instance to get or create. Must have a parameterless constructor.
+ /// How the instance should be shared across tests.
+ /// The data generator metadata (used to extract the test class type).
+ /// The sharing key (required for ).
+ /// The shared or newly created instance.
+ ///
+ /// Thrown when is null/empty and is .
+ ///
+ /// Thrown when is not a valid value.
+ public static T GetOrCreate(SharedType sharedType, DataGeneratorMetadata dataGeneratorMetadata, string? key = null) where T : new()
+ {
+ return GetOrCreate(sharedType, dataGeneratorMetadata, key, static () => new T());
+ }
+
+ ///
+ /// Gets or creates a shared instance based on the specified sharing type, using the default constructor.
+ ///
+ /// The type of instance to get or create. Must have a parameterless constructor.
+ /// How the instance should be shared across tests.
+ /// The test class type (required for ).
+ /// The sharing key (required for ).
+ /// The shared or newly created instance.
+ ///
+ /// Thrown when is null and is or ,
+ /// or when is null/empty and is .
+ ///
+ /// Thrown when is not a valid value.
+ public static T GetOrCreate(SharedType sharedType, Type? testClassType = null, string? key = null) where T : new()
+ {
+ return GetOrCreate(sharedType, testClassType, key, static () => new T());
+ }
+
+ ///
+ /// Gets or creates a shared instance based on the specified sharing type.
+ ///
+ /// The type of instance to get or create.
+ /// How the instance should be shared across tests.
+ /// The test class type (required for ).
+ /// The sharing key (required for ).
+ /// A factory function to create the instance if not already cached.
+ /// The shared or newly created instance.
+ ///
+ /// Thrown when is null and is or ,
+ /// or when is null/empty and is .
+ ///
+ /// Thrown when is not a valid value.
+ public static T GetOrCreate(SharedType sharedType, Type? testClassType, string? key, Func factory)
+ {
+ _ = factory ?? throw new ArgumentNullException(nameof(factory));
+
+ return sharedType switch
+ {
+ SharedType.None => factory(),
+ SharedType.PerTestSession => (T)TestDataContainer.GetGlobalInstance(typeof(T), _ => factory()!)!,
+ SharedType.PerClass => GetForClass(testClassType, factory),
+ SharedType.Keyed => GetForKey(key, factory),
+ SharedType.PerAssembly => GetForAssembly(testClassType, factory),
+ _ => throw new ArgumentOutOfRangeException(nameof(sharedType), sharedType, "Invalid SharedType value.")
+ };
+ }
+
+ ///
+ /// Gets or creates a shared instance based on the specified sharing type.
+ ///
+ /// The type of instance to get or create.
+ /// How the instance should be shared across tests.
+ /// The data generator metadata (used to extract the test class type).
+ /// The sharing key (required for ).
+ /// A factory function to create the instance if not already cached.
+ /// The shared or newly created instance.
+ ///
+ /// Thrown when is null/empty and is .
+ ///
+ /// Thrown when is not a valid value.
+ public static T GetOrCreate(SharedType sharedType, DataGeneratorMetadata dataGeneratorMetadata, string? key, Func factory)
+ {
+ var testClassType = TestClassTypeHelper.GetTestClassType(dataGeneratorMetadata);
+ return GetOrCreate(sharedType, testClassType, key, factory);
+ }
+
+ ///
+ /// Gets or creates a shared instance based on the specified sharing type.
+ ///
+ /// How the instance should be shared across tests.
+ /// The type of instance to get or create.
+ /// The data generator metadata (used to extract the test class type).
+ /// The sharing key (required for ).
+ /// A factory function to create the instance if not already cached.
+ /// The shared or newly created instance.
+ ///
+ /// Thrown when is null/empty and is .
+ ///
+ /// Thrown when is not a valid value.
+ public static object? GetOrCreate(
+ SharedType sharedType,
+ [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)]
+ Type type,
+ DataGeneratorMetadata dataGeneratorMetadata,
+ string? key,
+ Func