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
717 changes: 0 additions & 717 deletions TUnit.Core.SourceGenerator/Generators/AotMethodInvocationGenerator.cs

This file was deleted.

202 changes: 0 additions & 202 deletions TUnit.Core.SourceGenerator/Generators/DataSourceHelpersGenerator.cs

This file was deleted.

46 changes: 0 additions & 46 deletions TUnit.Core/Helpers/DataSourceHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,41 +292,6 @@ public static T InvokeIfFunc<T>(object? value)
return [() => Task.FromResult<object?>(InvokeIfFunc(data))];
}


/// <summary>
/// AOT-compatible runtime dispatcher for data source property initialization.
/// This will be populated by the generated DataSourceHelpers class.
/// </summary>
private static readonly Dictionary<Type, Func<object, MethodMetadata, string, Task>> PropertyInitializers = new();

/// <summary>
/// Register a type-specific property initializer (called by generated code)
/// </summary>
public static void RegisterPropertyInitializer<T>(Func<T, MethodMetadata, string, Task> initializer)
{
PropertyInitializers[typeof(T)] = (instance, testInfo, sessionId) =>
initializer((T)instance, testInfo, sessionId);
}

/// <summary>
/// Initialize data source properties on an instance using registered type-specific helpers
/// </summary>
public static async Task InitializeDataSourcePropertiesAsync(object? instance, MethodMetadata testInformation, string testSessionId)
{
if (instance == null)
{
return;
}

var instanceType = instance.GetType();

if (PropertyInitializers.TryGetValue(instanceType, out var initializer))
{
await initializer(instance, testInformation, testSessionId);
}
// If no initializer is registered, the type has no data source properties
}

public static object?[] ToObjectArray(this object? item)
{
item = InvokeIfFunc(item);
Expand Down Expand Up @@ -618,15 +583,4 @@ public static void RegisterTypeCreator<T>(Func<MethodMetadata, string, Task<T>>

return null;
}

/// <summary>
/// Resolves a data source property value at runtime for an existing instance.
/// This is used when we need to set init-only properties via reflection.
/// </summary>
public static Task<object?> ResolveDataSourcePropertyAsync(object instance, string propertyName, MethodMetadata testInformation, string testSessionId)
{
// For now, return a default value - the runtime resolution is complex
// In practice, this should be rare since most data sources can be resolved at compile time
return Task.FromResult<object?>(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2006,20 +2006,17 @@ namespace .Helpers
public static class DataSourceHelpers
{
public static <.<object?>>[] HandleTupleValue(object? value, bool shouldUnwrap) { }
public static . InitializeDataSourcePropertiesAsync(object? instance, .MethodMetadata testInformation, string testSessionId) { }
public static object? InvokeIfFunc(object? value) { }
public static T InvokeIfFunc<T>(object? value) { }
public static bool IsTuple(object? obj) { }
public static .<object?> ProcessDataSourceResult<T>(T data) { }
public static .<object?> ProcessDataSourceResultGeneric<T>(T data) { }
public static .<object?> ProcessEnumerableDataSource<T>(.<T> enumerable) { }
public static <.<object?>>[] ProcessTestDataSource<T>(T data, int expectedParameterCount = -1) { }
public static void RegisterPropertyInitializer<T>(<T, .MethodMetadata, string, .> initializer) { }
public static void RegisterTypeCreator<T>(<.MethodMetadata, string, .<T>> creator) { }
[.("Data source resolution may require dynamic code generation")]
[.("Property types are resolved through reflection")]
public static .<object?> ResolveDataSourceForPropertyAsync([.(..None | ..PublicParameterlessConstructor | ..PublicFields | ..NonPublicFields | ..PublicProperties)] containingType, string propertyName, .MethodMetadata testInformation, string testSessionId) { }
public static .<object?> ResolveDataSourcePropertyAsync(object instance, string propertyName, .MethodMetadata testInformation, string testSessionId) { }
public static object?[] ToObjectArray(this object? item) { }
public static object?[] ToObjectArrayWithTypes(this object? item, []? expectedTypes) { }
[return: .(new string[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2006,20 +2006,17 @@ namespace .Helpers
public static class DataSourceHelpers
{
public static <.<object?>>[] HandleTupleValue(object? value, bool shouldUnwrap) { }
public static . InitializeDataSourcePropertiesAsync(object? instance, .MethodMetadata testInformation, string testSessionId) { }
public static object? InvokeIfFunc(object? value) { }
public static T InvokeIfFunc<T>(object? value) { }
public static bool IsTuple(object? obj) { }
public static .<object?> ProcessDataSourceResult<T>(T data) { }
public static .<object?> ProcessDataSourceResultGeneric<T>(T data) { }
public static .<object?> ProcessEnumerableDataSource<T>(.<T> enumerable) { }
public static <.<object?>>[] ProcessTestDataSource<T>(T data, int expectedParameterCount = -1) { }
public static void RegisterPropertyInitializer<T>(<T, .MethodMetadata, string, .> initializer) { }
public static void RegisterTypeCreator<T>(<.MethodMetadata, string, .<T>> creator) { }
[.("Data source resolution may require dynamic code generation")]
[.("Property types are resolved through reflection")]
public static .<object?> ResolveDataSourceForPropertyAsync([.(..None | ..PublicParameterlessConstructor | ..PublicFields | ..NonPublicFields | ..PublicProperties)] containingType, string propertyName, .MethodMetadata testInformation, string testSessionId) { }
public static .<object?> ResolveDataSourcePropertyAsync(object instance, string propertyName, .MethodMetadata testInformation, string testSessionId) { }
public static object?[] ToObjectArray(this object? item) { }
public static object?[] ToObjectArrayWithTypes(this object? item, []? expectedTypes) { }
[return: .(new string[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1887,18 +1887,15 @@ namespace .Helpers
public static class DataSourceHelpers
{
public static <.<object?>>[] HandleTupleValue(object? value, bool shouldUnwrap) { }
public static . InitializeDataSourcePropertiesAsync(object? instance, .MethodMetadata testInformation, string testSessionId) { }
public static object? InvokeIfFunc(object? value) { }
public static T InvokeIfFunc<T>(object? value) { }
public static bool IsTuple(object? obj) { }
public static .<object?> ProcessDataSourceResult<T>(T data) { }
public static .<object?> ProcessDataSourceResultGeneric<T>(T data) { }
public static .<object?> ProcessEnumerableDataSource<T>(.<T> enumerable) { }
public static <.<object?>>[] ProcessTestDataSource<T>(T data, int expectedParameterCount = -1) { }
public static void RegisterPropertyInitializer<T>(<T, .MethodMetadata, string, .> initializer) { }
public static void RegisterTypeCreator<T>(<.MethodMetadata, string, .<T>> creator) { }
public static .<object?> ResolveDataSourceForPropertyAsync( containingType, string propertyName, .MethodMetadata testInformation, string testSessionId) { }
public static .<object?> ResolveDataSourcePropertyAsync(object instance, string propertyName, .MethodMetadata testInformation, string testSessionId) { }
public static object?[] ToObjectArray(this object? item) { }
public static object?[] ToObjectArrayWithTypes(this object? item, []? expectedTypes) { }
[return: .(new string[] {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
[assembly: .(".NETCoreApp,Version=v8.0", FrameworkDisplayName=".NET 8.0")]
namespace
{
public static class AotMethodInvokers
{
public static string GetMethodKey(string typeName, string methodName, int parameterCount = 0) { }
public static .<object?> InvokeMethodAsync(string methodKey, object? instance, params object?[]? parameters) { }
}
}
namespace
{
public class BrowserTest : .PlaywrightTest
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
[assembly: .(".NETCoreApp,Version=v9.0", FrameworkDisplayName=".NET 9.0")]
namespace
{
public static class AotMethodInvokers
{
public static string GetMethodKey(string typeName, string methodName, int parameterCount = 0) { }
public static .<object?> InvokeMethodAsync(string methodKey, object? instance, params object?[]? parameters) { }
}
}
namespace
{
public class BrowserTest : .PlaywrightTest
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
[assembly: .(".NETStandard,Version=v2.0", FrameworkDisplayName=".NET Standard 2.0")]
namespace
{
public static class AotMethodInvokers
{
public static string GetMethodKey(string typeName, string methodName, int parameterCount = 0) { }
public static .<object?> InvokeMethodAsync(string methodKey, object? instance, params object?[]? parameters) { }
}
}
namespace
{
public class BrowserTest : .PlaywrightTest
{
Expand Down
Loading