SpecFlow.VS icon indicating copy to clipboard operation
SpecFlow.VS copied to clipboard

Rename Step Errors in Some Visual Studio 2022 Projects

Open CRohm42 opened this issue 3 years ago • 5 comments

Used Visual Studio

Visual Studio 2022

Are the latest Visual Studio updates installed?

Yes

SpecFlow Section in app.config or content of specflow.json

{ "$schema": "https://specflow.org/specflow-config.json", "livingDocGenerator": { "enabled": true, "filePath": "JHAutomation\LivingDoc\LivingDoc_[PID-{ProcessId}][TID-{ThreadId}][{now:MM-dd-yyyy_HH.mm.ss}].json" } }

Issue Description

Clicking "Rename Step" works as expected in some VS2022 projects, but in other VS2022 projects it doesn't work and has the following Behavior (see Steps to Reproduce)

Steps to Reproduce

  1. Select Rename Step
  2. Visual Studio navigates to the correct steps file and binding (just like it does when Rename Step works as expected)
  3. This Rename Steps - SpecFlow window doesn't launch as expected
  4. Instead, an error window displays:

"SpecFlow: Rename Step - The following problems occurred: No step definition found that is related to this position"

  1. SpecFlow Output displays:

Info: PerformJump: Jumping to Defined: [Given(the user is on the '([^']*)' page)]: GeneralSteps.GivenTheUserIsOnThePage(String) at [Project Directory]\GeneralSteps.cs(51,9) Warning: ShowProblem: User Notification: The following problems occurred: No step definition found that is related to this position

Using SpecFlow for VS 2022 Extension v2022.1.75.53377.

Any ideas on what may be causing the issue?

Thank you!

Link to Repository Project

No response

CRohm42 avatar Sep 27 '22 12:09 CRohm42

Would love an update on this one - we're seeing this issue too! Rename has been flaky on whether it'll work or not.

jrod567 avatar Nov 07 '22 20:11 jrod567

@CRohm42 @jrod567 Does the problem also appears in these projects when you just simply try to use "Go To Definition" from the scenario step? Or is this specific to the rename?

Also could you please record the full version number of VS2022 (from the help / about), like "Version 17.3.6"?

gasparnagy avatar Nov 09 '22 08:11 gasparnagy

This does not affect "Go To Definition" or "Define Steps." Only "Rename Step" has the issue.

VS2022 version = 17.3.4.

CRohm42 avatar Nov 09 '22 13:11 CRohm42

An interesting note in troubleshooting this - If I take the exact same project and copy it to another folder, build and use rename - it works fine.

In the process of using Rename, it takes you to the correct step definition, but throws the error message just before displaying the usual rename edit form.

I tried clearing the spec cache files in %temp% and no change; very odd.

jrod567 avatar Nov 14 '22 14:11 jrod567

@gasparnagy I know it's been a while but still struggling with this issue. HOWEVER, I've been able to narrow the issue down and can reproduce/workaround.

First: Rename Step and Find Step Definition Usages are both affected for this issue.

What I've discovered: Opening VS, (no Start window) and directly opening a repo in the lower-right GIT menu . Choose repo and let the repo auto-load the default solution; this is where the issue is introduced. Rebuild solution. From a step definition, using the "Find Step Definition Usages" yields this:

image

No step definition usages are found shows in the context menu.

However, opening the exact same project/repo but using the File-> Open Project/Solution (or Recent Projects flyout), everything will work. NOTE: In the example above, b/c I built in the non-working solution, I need to rebuild for Rename/Find Step Def Usages to work after opening this way. Specflow output:

image

I can confirm this issue in VS v17.3.1 and v17.5.0. I tried this on another user's machine (VS v17.3.4) and they do not have my symptoms which is strange.

In any case, the root issue seems to be in the way VS (or the SpecFlow extension) is being loaded when opening a solution with the .sln file (File -> Open Project/Solution or Recent projects) vs. using the lower-right hand GIT menu to select a repo and auto-load the solution.

Hope this helps! Any ideas?

jrod567 avatar Feb 22 '23 14:02 jrod567