Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c04cb43
fix(sourcegen): infer generic method types from any MethodDataSource …
thomhurst Oct 19, 2026
113caa7
fix(sourcegen): share MethodDataSource member resolution between fact…
thomhurst Oct 19, 2026
b6c4265
fix(sourcegen): call the chosen MethodDataSource overload the way ref…
thomhurst Oct 19, 2026
316efc9
test(sourcegen): cover an exact argument type beating an implicit con…
thomhurst Oct 19, 2026
9a53b50
fix(sourcegen): keep the type of MethodDataSource Arguments values
thomhurst Oct 19, 2026
2cce80f
fix: pick the MethodDataSource overload that accepts a null argument …
thomhurst Oct 20, 2026
fa94fe3
fix: handle field data sources, parameters without Arguments, and nul…
thomhurst Oct 20, 2026
1bf7dc9
fix: keep private field data sources on the reflection fallback, brea…
thomhurst Oct 20, 2026
b9a65ec
fix(sourcegen): keep a leading CancellationToken before a single tupl…
thomhurst Oct 20, 2026
90058d9
test(sourcegen): cover an overloaded data method selected without Arg…
thomhurst Oct 20, 2026
a105d29
fix(sourcegen): throw a descriptive error for a missing data source a…
thomhurst Oct 20, 2026
61230b6
perf(sourcegen): look up MethodDataSource row wrapper types once per …
thomhurst Oct 20, 2026
1945e14
fix(sourcegen): read private data source fields and properties in a t…
thomhurst Oct 20, 2026
6ba76de
fix(sourcegen): split a private object-typed data source into rows by…
thomhurst Oct 20, 2026
02a9e8c
fix(core): keep a null private data member as one row holding null
thomhurst Oct 20, 2026
13a95a0
test: cover a private data source member on a generic class
thomhurst Oct 20, 2026
aa09236
Merge remote-tracking branch 'origin/main' into fix/issue-7108-generi…
thomhurst Oct 20, 2026
d41ef61
Merge remote-tracking branch 'origin/main' into fix/issue-7108-generi…
thomhurst Oct 20, 2026
e4eade4
Merge remote-tracking branch 'origin/main' into fix/issue-7108-generi…
thomhurst Oct 20, 2026
cf851aa
fix(sourcegen): pick the MethodDataSource overload reflection mode ca…
thomhurst Oct 20, 2026
d265b7d
fix(sourcegen): split object-typed fields by runtime value; skip infe…
thomhurst Oct 20, 2026
81a9d78
fix: guard the overload specificity checks instead of relying on Debu…
thomhurst Oct 20, 2026
e2d678f
test: cover inherited protected data sources and a generic test with …
thomhurst Oct 20, 2026
c71d27e
test: read the instance object field through [MethodDataSource]; fix …
thomhurst Oct 20, 2026
890cfc8
Merge remote-tracking branch 'origin/main' into fix/issue-7108-generi…
thomhurst Oct 20, 2026
93db536
test(analyzers): pin the generic data method lookup in TUnit0001
thomhurst Oct 20, 2026
25c8c29
Merge origin/main; escape keyword-named data source members; fix net4…
thomhurst Oct 20, 2026
04dc119
test: drop the reflection-mode skip now that #7173 is fixed
thomhurst Oct 20, 2026
51792a4
fix(sourcegen): infer generic row types through only the delegate lay…
thomhurst Oct 20, 2026
d3035e5
Merge remote-tracking branch 'origin/main' into fix/issue-7108-generi…
thomhurst Oct 20, 2026
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
338 changes: 280 additions & 58 deletions src/TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions tests/TUnit.Core.SourceGenerator.Tests/Bugs/7108/Tests7108.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace TUnit.Core.SourceGenerator.Tests;

internal class Tests7108 : TestsBase
{
[Test]
public Task Test() => RunTest(Path.Combine(
Git.TestsDirectory.FullName,
"TUnit.TestProject",
"Bugs",
"_7108",
"GenericMethodNonTupleMethodDataSourceTests.cs"),
_ => Task.CompletedTask);
}
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,11 @@ internal static class TUnit_TestProject_MethodDataSourceDrivenTests__TestSource
new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod")
{
Arguments = new object[] { 5 },
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()),
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () =>
{
var arguments = new object[] { 5 };
return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((int)arguments[0]));
}),
},
},
parameters: global::TUnit.Core.ParameterMetadataFactory.ForMethod(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), "DataSource_Method3", false, new global::TUnit.Core.ParameterMetadata[]
Expand Down Expand Up @@ -285,7 +289,11 @@ internal static class TUnit_TestProject_MethodDataSourceDrivenTests__TestSource
new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod")
{
Arguments = new object[] { "Hello World!", 6, true },
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()),
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () =>
{
var arguments = new object[] { "Hello World!", 6, true };
return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2]));
}),
},
new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod")
{
Expand All @@ -294,7 +302,11 @@ internal static class TUnit_TestProject_MethodDataSourceDrivenTests__TestSource
new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod")
{
Arguments = new object[] { "Hello World!", 8, true },
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()),
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () =>
{
var arguments = new object[] { "Hello World!", 8, true };
return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2]));
}),
},
},
parameters: global::TUnit.Core.ParameterMetadataFactory.ForMethod(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), "DataSource_Method4", false, new global::TUnit.Core.ParameterMetadata[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,11 @@ internal static class TUnit_TestProject_MethodDataSourceDrivenTests__TestSource
new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod")
{
Arguments = new object[] { 5 },
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()),
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () =>
{
var arguments = new object[] { 5 };
return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((int)arguments[0]));
}),
},
},
parameters: global::TUnit.Core.ParameterMetadataFactory.ForMethod(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), "DataSource_Method3", false, new global::TUnit.Core.ParameterMetadata[]
Expand Down Expand Up @@ -285,7 +289,11 @@ internal static class TUnit_TestProject_MethodDataSourceDrivenTests__TestSource
new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod")
{
Arguments = new object[] { "Hello World!", 6, true },
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()),
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () =>
{
var arguments = new object[] { "Hello World!", 6, true };
return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2]));
}),
},
new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod")
{
Expand All @@ -294,7 +302,11 @@ internal static class TUnit_TestProject_MethodDataSourceDrivenTests__TestSource
new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod")
{
Arguments = new object[] { "Hello World!", 8, true },
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()),
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () =>
{
var arguments = new object[] { "Hello World!", 8, true };
return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2]));
}),
},
},
parameters: global::TUnit.Core.ParameterMetadataFactory.ForMethod(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), "DataSource_Method4", false, new global::TUnit.Core.ParameterMetadata[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,11 @@ internal static class TUnit_TestProject_MethodDataSourceDrivenTests__TestSource
new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod")
{
Arguments = new object[] { 5 },
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()),
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () =>
{
var arguments = new object[] { 5 };
return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((int)arguments[0]));
}),
},
},
parameters: global::TUnit.Core.ParameterMetadataFactory.ForMethod(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), "DataSource_Method3", false, new global::TUnit.Core.ParameterMetadata[]
Expand Down Expand Up @@ -285,7 +289,11 @@ internal static class TUnit_TestProject_MethodDataSourceDrivenTests__TestSource
new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod")
{
Arguments = new object[] { "Hello World!", 6, true },
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()),
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () =>
{
var arguments = new object[] { "Hello World!", 6, true };
return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2]));
}),
},
new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod")
{
Expand All @@ -294,7 +302,11 @@ internal static class TUnit_TestProject_MethodDataSourceDrivenTests__TestSource
new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod")
{
Arguments = new object[] { "Hello World!", 8, true },
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()),
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () =>
{
var arguments = new object[] { "Hello World!", 8, true };
return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2]));
}),
},
},
parameters: global::TUnit.Core.ParameterMetadataFactory.ForMethod(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), "DataSource_Method4", false, new global::TUnit.Core.ParameterMetadata[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,11 @@ internal static class TUnit_TestProject_MethodDataSourceDrivenTests__TestSource
new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod")
{
Arguments = new object[] { 5 },
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()),
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () =>
{
var arguments = new object[] { 5 };
return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((int)arguments[0]));
}),
},
},
parameters: global::TUnit.Core.ParameterMetadataFactory.ForMethod(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), "DataSource_Method3", false, new global::TUnit.Core.ParameterMetadata[]
Expand Down Expand Up @@ -285,7 +289,11 @@ internal static class TUnit_TestProject_MethodDataSourceDrivenTests__TestSource
new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod")
{
Arguments = new object[] { "Hello World!", 6, true },
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()),
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () =>
{
var arguments = new object[] { "Hello World!", 6, true };
return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2]));
}),
},
new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod")
{
Expand All @@ -294,7 +302,11 @@ internal static class TUnit_TestProject_MethodDataSourceDrivenTests__TestSource
new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod")
{
Arguments = new object[] { "Hello World!", 8, true },
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()),
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () =>
{
var arguments = new object[] { "Hello World!", 8, true };
return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2]));
}),
},
},
parameters: global::TUnit.Core.ParameterMetadataFactory.ForMethod(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), "DataSource_Method4", false, new global::TUnit.Core.ParameterMetadata[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,11 @@ internal static class TUnit_TestProject_MethodDataSourceDrivenTests__TestSource
new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod")
{
Arguments = new object[] { 5 },
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()),
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () =>
{
var arguments = new object[] { 5 };
return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((int)arguments[0]));
}),
},
},
parameters: global::TUnit.Core.ParameterMetadataFactory.ForMethod(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), "DataSource_Method3", false, new global::TUnit.Core.ParameterMetadata[]
Expand Down Expand Up @@ -285,7 +289,11 @@ internal static class TUnit_TestProject_MethodDataSourceDrivenTests__TestSource
new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod")
{
Arguments = new object[] { "Hello World!", 6, true },
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()),
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () =>
{
var arguments = new object[] { "Hello World!", 6, true };
return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2]));
}),
},
new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod")
{
Expand All @@ -294,7 +302,11 @@ internal static class TUnit_TestProject_MethodDataSourceDrivenTests__TestSource
new global::TUnit.Core.MethodDataSourceAttribute("SomeMethod")
{
Arguments = new object[] { "Hello World!", 8, true },
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () => global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod()),
Factory = static dataGeneratorMetadata => global::TUnit.Core.Helpers.DataSourceFactories.FromValue(static () =>
{
var arguments = new object[] { "Hello World!", 8, true };
return global::TUnit.TestProject.MethodDataSourceDrivenTests.SomeMethod(((string)arguments[0]), ((int)arguments[1]), ((bool)arguments[2]));
}),
},
},
parameters: global::TUnit.Core.ParameterMetadataFactory.ForMethod(typeof(global::TUnit.TestProject.MethodDataSourceDrivenTests), "DataSource_Method4", false, new global::TUnit.Core.ParameterMetadata[]
Expand Down
Loading
Loading