SpecFlow.VisualStudio
SpecFlow.VisualStudio copied to clipboard
Visual Studio fails to bind when attributes use const string interpolation
SpecFlow Version
3
Which test runner are you using?
NUnit
Test Runner Version Number
N/A
.NET Implementation
.NET 5.0
Project Format of the SpecFlow project
Sdk-style project format
.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
No response
Issue Description
If your project uses the C#10 feature "constant interpolated strings" in your steps binding argument, the SpecFlow extension will no longer recognize the step as bound. The tests seem to run just fine even from the VS test explorer.
Steps to Reproduce
- Create a SpecFlow project.
- If reproducing before C#10 has been shipped, add this to your .csproj <PropertyGroup> node <LangVersion>preview</LangVersion>
- In the StepDefinition attributes, add interpolation, for example create a const string with the whole text and insert that into the interpolated string.
- Open the feature file with the affected.
Link to Repro Project
https://github.com/kapros/SpecFlowInterpolatedStrings
In VS2017 and VS2019 this will never work. We are using another concept in the VS2022 extension and there this could work. @epresi & @gasparnagy What do you thing about this?
Also this is a VS issue, so I move it into the right repo
@kapros @SabotageAndi Yes, this will work in the VS2022 extension, but not in the VS2019 extension. (I guess it would also work with Deveroom in VS2019 as it uses the same binding discovery mechanism as the VS2022 extension.)
As @kapros provided an repro, we should verify this with the VS2022 extension to make sure it works. I would keep the issue open until we did that.
@gasparnagy I have just switched over to Deveroom for VS2019 and it works just fine.