Skip to content

Conversation

@clrudolphi
Copy link
Contributor

This PR replaces part of #121.

🤔 What's changed?

Modified the SnippetsService to generate asynchronous step bindings based upon the StepDefinitionSkeletonStyle setting in the reqnroll.json configuration file.

This PR does NOT include any UI modifications. The behavior is driven solely by the configuration file.

⚡️ What's your motivation?

To ease the developer transition to async step binding methods.

🏷️ What kind of change is this?

  • ⚡ New feature (non-breaking change which adds new behaviour)

♻️ Anything particular you want feedback on?

Anything?

📋 Checklist:

  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • Users should know about my change
    • I have added an entry to the "[vNext]" section of the CHANGELOG, linking to this pull request & included my GitHub handle to the release contributors list.

… the reqnroll.json file when generating snippets (sync or async).

Added unit tests for the new skeletonStyle enum deserialization.
Added unit test for the SnippetService.
Added Spec test in the DefineStepsCommand spec for the generation of async and sync snippets.
@clrudolphi clrudolphi requested a review from gasparnagy October 22, 2025 20:40
@clrudolphi clrudolphi self-assigned this Oct 22, 2025
@304NotModified
Copy link
Member

I like to test and review this, but I have hard time to test this. Are there some (easy) steps to follow?

@gasparnagy
Copy link
Contributor

I like to test and review this, but I have hard time to test this. Are there some (easy) steps to follow?

I think it is just

  • having a Reqnroll project
  • set trace/stepDefinitionSkeletonStyle in the config to AsyncCucumberExpressionAttribute (or others from here),
  • maybe build the project
  • add a new undefined step to one of the scenarios
  • invoke "define steps" command from context menu

@304NotModified
Copy link
Member

304NotModified commented Dec 4, 2025

Thanks, but to be more clear, I mean using this branch. With the experimental VS instance most of the time the plugin isn't installed when debugging/running this branch from VS2022 (Haven't tested VS2026). Or sometimes an old version is hanging (and that's hard to see)

Another option is to install it manually but that is cumbersome (multiple restarts VS) and not possible to debug then? (Or could I attach to a process?)

@gasparnagy
Copy link
Contributor

Thanks, but to be more clear, I mean using this branch. With the experimental VS instance most of the time the plugin isn't installed when debugging/running this branch from VS2022 (Haven't tested VS2026). Or sometimes an old version is hanging (and that's hard to see)

Another option is to install it manually but that is cumbersome (multiple restarts VS) and not possible to debug then? (Or could I attach to a process?)

For me the exp hive support from VS2022 was working in a quite stable way. This is my daily routine:

  • I keep the configuration as "TestDebug" - that builds all projects, except the "Reqnroll.VisualStudio.Package". I do my TDD dev that way.
  • Once I want to check it live, I build the "Reqnroll.VisualStudio.Package" from the solution explorer context menu. I observe (double check) that it shows something like his in the build output: 6>Reqnroll.VisualStudio.Package -> W:\Reqnroll\Reqnroll.VisualStudio\Reqnroll.VisualStudio.Package\bin\Debug\net481\Reqnroll.VisualStudio.Package.vsix 6>Rename: bin\Debug\net481\Reqnroll.VisualStudio.Package.vsix -> bin\Debug\net481\Reqnroll.VisualStudio.Package.v2025.3.99999.vsix
  • Then I open the exp hive from start menu ("Start Experimental Instance of Visual Studio 2022") for testing, the package will be loaded automatically. (I use a different color theme for my exp hive instance, so that I can easily spot out)
  • If I need to debug, I attach my normal VS to the exp hive devenv.
  • Once I'm done with testing, I close exp hive instance (otherwise building "Reqnroll.VisualStudio.Package" will not work)

In very rare cases, the exp hive gets corrupted. In this case what I do:

  1. Open exp hive from start menu and uninstall reqnroll extension. I close to make the uninstall fully finished and restart the exp hive again so that it updates all caches to the uninstalled status.
  2. If this does not help (even more rare), I close exp hive and go to the extension install location (for me for VS2022 this is C:\Users\gaspar\AppData\Local\Microsoft\VisualStudio\17.0_d817ce1bExp\Extensions). I delete the "Reqnroll" folder manually. (With a clean setup there should be no other subfolders there.)
  3. If this still does not help (extreme rare), I invoke "Reset the Visual Studio 2022 Experimental Instance" from start menu.

I hope this helps.

@304NotModified
Copy link
Member

304NotModified commented Dec 14, 2025

Thanks, but to be more clear, I mean using this branch. With the experimental VS instance most of the time the plugin isn't installed when debugging/running this branch from VS2022 (Haven't tested VS2026). Or sometimes an old version is hanging (and that's hard to see)
Another option is to install it manually but that is cumbersome (multiple restarts VS) and not possible to debug then? (Or could I attach to a process?)

For me the exp hive support from VS2022 was working in a quite stable way. This is my daily routine:

  • I keep the configuration as "TestDebug" - that builds all projects, except the "Reqnroll.VisualStudio.Package". I do my TDD dev that way.
  • Once I want to check it live, I build the "Reqnroll.VisualStudio.Package" from the solution explorer context menu. I observe (double check) that it shows something like his in the build output: 6>Reqnroll.VisualStudio.Package -> W:\Reqnroll\Reqnroll.VisualStudio\Reqnroll.VisualStudio.Package\bin\Debug\net481\Reqnroll.VisualStudio.Package.vsix 6>Rename: bin\Debug\net481\Reqnroll.VisualStudio.Package.vsix -> bin\Debug\net481\Reqnroll.VisualStudio.Package.v2025.3.99999.vsix
  • Then I open the exp hive from start menu ("Start Experimental Instance of Visual Studio 2022") for testing, the package will be loaded automatically. (I use a different color theme for my exp hive instance, so that I can easily spot out)
  • If I need to debug, I attach my normal VS to the exp hive devenv.
  • Once I'm done with testing, I close exp hive instance (otherwise building "Reqnroll.VisualStudio.Package" will not work)

I tried this

And after testing with reqnroll.json

{
  "$schema": "https://schemas.reqnroll.net/reqnroll-config-latest.json",
  "trace": {
    "stepDefinitionSkeletonStyle": "AsyncCucumberExpressionAttribute"
  }
}

I get:

[Reqnroll] System.Text.Json.JsonException: The JSON value could not be converted to Reqnroll.BindingSkeletons.StepDefinitionSkeletonStyle. Path: $.trace.stepDefinitionSkeletonStyle | LineNumber: 3 | BytePositionInLine: 69.
   at System.Text.Json.ThrowHelper.ThrowJsonException(String message)
   at System.Text.Json.Serialization.Converters.EnumConverter`1.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
   at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.PopulatePropertiesFastPath(Object obj, JsonTypeInfo jsonTypeInfo, JsonSerializerOptions options, Utf8JsonReader& reader, ReadStack& state)
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.PopulatePropertiesFastPath(Object obj, JsonTypeInfo jsonTypeInfo, JsonSerializerOptions options, Utf8JsonReader& reader, ReadStack& state)
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Deserialize(Utf8JsonReader& reader, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo`1 jsonTypeInfo, Nullable`1 actualByteCount)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo`1 jsonTypeInfo)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonTypeInfo`1 jsonTypeInfo)
   at Reqnroll.Configuration.JsonConfig.JsonConfigurationLoader.LoadJson(ReqnrollConfiguration reqnrollConfiguration, String jsonContent)
   at Reqnroll.Configuration.ConfigurationLoader.LoadFromConfigSource(ReqnrollConfiguration reqnrollConfiguration, IReqnrollConfigurationHolder reqnrollConfigurationHolder)
   at Reqnroll.Generator.Configuration.GeneratorConfigurationProviderExtensions.LoadConfiguration(IGeneratorConfigurationProvider configurationProvider, ReqnrollConfigurationHolder configurationHolder)
   at Reqnroll.Generator.Project.ProjectReader.ReadReqnrollProject(String projectFilePath, String rootNamespace)

I don't know if this still an old build of the extension. Could we maybe add a build date to the version? I really don't know if this is the lastest...

image

Also, how does the exp instance know to install the Reqnroll local extension?

In very rare cases, the exp hive gets corrupted. In this case what I do:

  1. Open exp hive from start menu and uninstall reqnroll extension. I close to make the uninstall fully finished and restart the exp hive again so that it updates all caches to the uninstalled status.

after this, if I start the exp, there is no reqnroll extension. Should I uninstall and install it every time? (that's really annoying)

@304NotModified
Copy link
Member

304NotModified commented Dec 14, 2025

OK I got something working now after some restarts.

And I get it working, but only this way:

  1. Use this config:
{
  "$schema": "https://schemas.reqnroll.net/reqnroll-config-latest.json",
  "trace": {
   // "stepDefinitionSkeletonStyle": "AsyncCucumberExpressionAttribute"
  }
}
  1. build
  2. change the config to this:
{
 "$schema": "https://schemas.reqnroll.net/reqnroll-config-latest.json",
 "trace": {
   "stepDefinitionSkeletonStyle": "AsyncCucumberExpressionAttribute"
 }
}
  1. build

now this works, but if I change the code with this config, I get the error

[Reqnroll] System.Text.Json.JsonException: The JSON value could not be converted to Reqnroll.BindingSkeletons.StepDefinitionSkeletonStyle. Path: $.trace.stepDefinitionSkeletonStyle | LineNumber: 3 | BytePositionInLine: 69.
   at System.Text.Json.ThrowHelper.ThrowJsonException(String message)
   at System.Text.Json.Serialization.Converters.EnumConverter`1.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
   at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.PopulatePropertiesFastPath(Object obj, JsonTypeInfo jsonTypeInfo, JsonSerializerOptions options, Utf8JsonReader& reader, ReadStack& state)
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.PopulatePropertiesFastPath(Object obj, JsonTypeInfo jsonTypeInfo, JsonSerializerOptions options, Utf8JsonReader& reader, ReadStack& state)
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Deserialize(Utf8JsonReader& reader, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo`1 jsonTypeInfo, Nullable`1 actualByteCount)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo`1 jsonTypeInfo)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonTypeInfo`1 jsonTypeInfo)
   at Reqnroll.Configuration.JsonConfig.JsonConfigurationLoader.LoadJson(ReqnrollConfiguration reqnrollConfiguration, String jsonContent)
   at Reqnroll.Configuration.ConfigurationLoader.LoadFromConfigSource(ReqnrollConfiguration reqnrollConfiguration, IReqnrollConfigurationHolder reqnrollConfigurationHolder)
   at Reqnroll.Generator.Configuration.GeneratorConfigurationProviderExtensions.LoadConfiguration(IGeneratorConfigurationProvider configurationProvider, ReqnrollConfigurationHolder configurationHolder)
   at Reqnroll.Generator.Project.ProjectReader.ReadReqnrollProject(String projectFilePath, String rootNamespace)

maybe first something should be changed in the reqnroll project itself?

@gasparnagy
Copy link
Contributor

@304NotModified Oh. The problem is with the PR, I fear. Let me ckeck.

Copy link
Contributor

@gasparnagy gasparnagy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested this and it worked for me.
@304NotModified I think in your case the problem was that the sample project that you have tested it with was with a Reqnroll version that did not support this enum value. It should only work with v3.2.0 or later

@gasparnagy gasparnagy merged commit 30f1ce5 into main Dec 17, 2025
1 check passed
@gasparnagy gasparnagy deleted the Feature-GenerateAsyncSnippets branch December 17, 2025 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants