Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: address second round of PR review feedback
- Add file-count assertion to snapshot test for 5118
- Replace silent typeof(object) fallback with defensive throw
- Add comment explaining why Factory makes ClassProvidingDataSource unnecessary
  • Loading branch information
thomhurst committed Mar 11, 2026
commit 425cb2e57d8a7dea2195d7a59d457dbb2bf6e494
3 changes: 2 additions & 1 deletion TUnit.Core.SourceGenerator.Tests/Bugs/5118/Tests5118.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ public Task Test() => RunTest(Path.Combine(Git.RootDirectory.FullName,
"AsyncClassMethodDataSourceTests.cs"),
async generatedFiles =>
{
});
await Assert.That(generatedFiles).HasCount().EqualTo(1);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,9 @@ private static void GenerateMethodDataSourceAttribute(CodeWriter writer, Attribu
}
else
{
// MethodDataSource(string) constructor
// MethodDataSource(string) constructor — ClassProvidingDataSource is intentionally null here
// because the Factory delegate (set below) already encodes the correct target type directly.
// The runtime attribute only needs ClassProvidingDataSource for reflection-based lookup.
writer.AppendLine($"new {attrTypeName}(\"{methodName}\")");
}
writer.AppendLine("{");
Expand Down
3 changes: 2 additions & 1 deletion TUnit.Core/Attributes/TestData/MethodDataSourceAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,8 @@ public MethodDataSourceAttribute(
{
ParameterMetadata param => param.Type,
PropertyMetadata prop => prop.Type,
_ => typeof(object)
_ => throw new InvalidOperationException(
$"Unexpected member metadata type {members[i].GetType().Name} in GetMemberTypes")
};
}
return types;
Expand Down
Loading