Open golonac opened 2 years ago
We have a unit test to check that we are using the instance we are passing via the Func to CreateSet: https://github.com/SpecFlowOSS/SpecFlow/blob/master/Tests/TechTalk.SpecFlow.RuntimeTests/AssistTests/TableHelperExtensionMethods/CreateSetHelperMethodTests_WithFunc.cs#L21
So I think something from your description and example. Please provide a complete project where we can reproduce the issue, that we can continue to look into this issue.
SpecFlow Version
3.9.40
Which test runner are you using?
xUnit
Test Runner Version Number
3.9.40
.NET Implementation
.NET 5.0
Project Format of the SpecFlow project
Classic project format using
<PackageReference>
tags.feature.cs files are generated using
SpecFlow.Tools.MsBuild.Generation NuGet package
Test Execution Method
Visual Studio Test Explorer
SpecFlow Section in app.config or content of specflow.json
{ "$schema": "https://specflow.org/specflow-config.json", "runtime": { "missingOrPendingStepsOutcome": "Ignore" } }
Issue Description
CreateSet(Table, Func<TableRow, T>) takes a table row and returns a set item of type T. However, if the type T is a class or record instead of a struct, the returned item is ignored and SpecFlow uses the default parsed item instead, somehow.
Reproduced in .NET 6. The dropdown didn't have it.
Steps to Reproduce
record SearchResult(string Value);
[StepArgumentTransformation] public static IEnumerable SearchResultTransform(Table table) =>
table.CreateSet(row => new SearchResult("new value"));
| Value | | original value |
Unexpectedly, CreateSet returns a SearchResult with the original value instead of the new value.
Link to Repro Project
No response