-
-
Notifications
You must be signed in to change notification settings - Fork 114
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description
The following code is a compilation error because the source generated extension method has lost the true default value of the exact parameter.
public class UnitTest1
{
[Test]
public async Task TestWithMemberData()
{
string[] items = new[] { "food", "bard" };
await Assert.That(items).ContainsMessage("foo"); // ERROR: parameter `bool exact` expected
}
}
public static partial class Assertions
{
[EditorBrowsable(EditorBrowsableState.Never)]
[GenerateAssertion(ExpectationMessage = "to contain message '{needle}'")]
public static bool ContainsMessage(this IEnumerable<string> strings, string needle, bool exact = true)
{
return strings.Any(x => exact ? x == needle : x.Contains(needle));
}
}Expected Behavior
Source generated extension preserves parameter defaults.
Actual Behavior
Parameter defaults lost
Steps to Reproduce
See above code
TUnit Version
1.15.0
.NET Version
NET 10
Operating System
Windows
IDE / Test Runner
dotnet CLI (dotnet test / dotnet run)
Error Output / Stack Trace
Additional Context
No response
IDE-Specific Issue?
- I've confirmed this issue occurs when running via
dotnet testordotnet run, not just in my IDE
Reactions are currently unavailable
Metadata
Metadata
Labels
bugSomething isn't workingSomething isn't working