Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
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
16 changes: 14 additions & 2 deletions 16 TUnit.Core/Attributes/TestData/MethodDataSourceAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,21 @@ public class MethodDataSourceAttribute : Attribute, IDataSourceAttribute
public string MethodNameProvidingDataSource { get; }

/// <summary>
/// Gets or sets an AOT-safe factory function for providing test data programmatically.
/// When set, this factory is used instead of reflection-based member lookup.
/// Gets or sets an AOT-safe factory function that provides test data without reflection.
/// </summary>
/// <remarks>
/// <para>
/// This property is <strong>automatically populated by the TUnit source generator</strong> at compile time
/// and is not intended to be set manually in attribute syntax. Because C# attributes only support
/// literal values as arguments, a <see cref="Func{T,TResult}"/> cannot be assigned in an attribute
/// declaration.
/// </para>
/// <para>
/// When the source generator processes a <c>[MethodDataSource]</c> attribute, it emits code that
/// sets this property to a generated delegate that invokes the named method directly — bypassing
/// reflection and enabling compatibility with Native AOT and IL trimming.
/// </para>
/// </remarks>
public Func<DataGeneratorMetadata, IAsyncEnumerable<Func<Task<object?[]?>>>>? Factory { get; set; }

/// <summary>
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.