From e5873ac8aafb0d171ab9442f843614981b22f4fc Mon Sep 17 00:00:00 2001 From: Martin Gasser Date: Wed, 11 Mar 2026 10:26:44 +0100 Subject: [PATCH] Use CallerArgumentExpression for TestDataRow by default. --- TUnit.Core/TestDataRow.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/TUnit.Core/TestDataRow.cs b/TUnit.Core/TestDataRow.cs index 3f542b147d..2c5f14489e 100644 --- a/TUnit.Core/TestDataRow.cs +++ b/TUnit.Core/TestDataRow.cs @@ -1,3 +1,5 @@ +using System.Runtime.CompilerServices; + namespace TUnit.Core; /// @@ -20,7 +22,7 @@ internal interface ITestDataRow /// The type of the test data. /// The actual test data to be passed to the test method. /// -/// Optional custom display name for the test case. +/// Optional custom display name for the test case. If not specified, the argument expression from is used. /// Supports parameter substitution using $paramName or $arg1, $arg2, etc. /// /// @@ -33,7 +35,7 @@ internal interface ITestDataRow /// /// public static IEnumerable<TestDataRow<(string Username, string Password)>> GetLoginData() /// { -/// yield return new(("admin", "secret123"), DisplayName: "Admin login"); +/// yield return new(("admin", "secret123")); // DisplayName '("admin", "secret123")' is inferred /// yield return new(("guest", "guest"), DisplayName: "Guest login"); /// yield return new(("", ""), DisplayName: "Empty credentials", Skip: "Not implemented yet"); /// } @@ -41,7 +43,7 @@ internal interface ITestDataRow /// public record TestDataRow( T Data, - string? DisplayName = null, + [CallerArgumentExpression(nameof(Data))] string? DisplayName = null, string? Skip = null, string[]? Categories = null ) : ITestDataRow