SpecFlow icon indicating copy to clipboard operation
SpecFlow copied to clipboard

intellisense for enum parameters

Open InvalidCast44 opened this issue 5 years ago • 6 comments

hi! let's take an example:

public enum EnumValues { Value1, Value2 }

[Given(@"I'm calling this step with this parameter here (.*)")] public void MyStep(EnumValues value) { }

i would like in feature file that intellisense:

  • first show step list, as it does now
  • shows list of EnumValues values when the cursor is at the EnumValues parameter location, if i choose MyStep

thanks

InvalidCast44 avatar Jan 10 '20 10:01 InvalidCast44

I think this is a very useful feature, especially when people with no or only little programming experience edit feature files.

So I implemented a first version and published it on branch StepArgumentSuggestions in my fork of SpecFlow.VisualStudio. All changes so far are included in commit 0554ca5.

There are still several shortcomings, e.g.

  • step argument completions are only getting triggered by typing space or the completion command (usually Ctrl-Space)
  • it only works when the step argument is not at the very end of the step's regex
  • the step definition needs to capture all characters for the step parameter (i.e. (.*)), something like (Value1|Value2) would not work

Still my changes already seem to work quite well for some standard cases. For testing I extended the calculator example with the following step binding:

    public enum Operation
    {
        Add, Sub, Mult, Div, Sqrt
    }

    [When(@"executing operation '(.*)'")]
    [When(@"executing (.*) operation")]
    public void WhenExecutingOperation(Operation op)
    {
        ScenarioContext.Current.Pending();
    }

Once the step is added to a feature file, I can select the default {op} text and type space to get a list of step argument suggestions.

Before continuing to work on this feature, I'd like to ask whether you would consider to merge it into the main line once it is reviewed and stable. I would also have some design questions.

Renreok avatar Mar 12 '21 09:03 Renreok

@Renreok From a feature perspective, I would definitely merge the PR. No question there. I can't say yet anything about the implementation. A review of it would take more time than I have at the moment. When you send a PR to the repo, I will ask somebody else from the team to have a look at it.

SabotageAndi avatar Mar 12 '21 15:03 SabotageAndi

Thank you for the quick reply. I would also have some design questions about my implementation (e.g. whether it would make sense to have a dedicated completion source for step arguments). I'm wondering what would be the best forum to discuss them - here, in a PR, or somewhere else?

Renreok avatar Mar 12 '21 16:03 Renreok

The best place would be out Discord Server in the #contributing channel: https://go.specflow.org/join-contributing-on-discord

SabotageAndi avatar Mar 15 '21 10:03 SabotageAndi

Since I already have a quite concrete solution proposal, I decided to write a PR. We can discuss some of the questions on the Discord Server if necessary.

Renreok avatar Mar 15 '21 13:03 Renreok

@Renreok Thanks for the PR. Sorry for the late answer, but available time was a little bit limited here. I will try to get someone from the team to have a look at the PR next week.

SabotageAndi avatar Mar 30 '21 14:03 SabotageAndi