Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bindings cannot be discovered in .NET 8 application #2726

Closed
mrpmorris opened this issue Nov 21, 2023 · 12 comments
Closed

Bindings cannot be discovered in .NET 8 application #2726

mrpmorris opened this issue Nov 21, 2023 · 12 comments
Labels

Comments

@mrpmorris
Copy link

SpecFlow Version

2021.0.200

Which test runner are you using?

xUnit

Test Runner Version Number

N/A

.NET Implementation

.NET 6.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

There isn't one

Issue Description

Warning: The project bindings (e.g. step definitions) could not be discovered. Navigation, step completion and other features are disabled.

Steps to Reproduce

  1. Create a new SpecFlow project
  2. Select xUnit
  3. Select .Net 6.0
  4. Right-click project and change the framework to .Net 8
  5. Save, Clean solution, Rebuild
  6. Close VS, reopen VS

Link to Repro Project

No response

@mrpmorris mrpmorris added the Bug label Nov 21, 2023
@renegadexx
Copy link

We also have the same problem with NUnit

@ThomasHeijtink
Copy link

I thought I saw a PR for this issue. But now I can't seem to find it any more. Did I hallucinate, or is the PR removed?

@OwendB1
Copy link

OwendB1 commented Nov 27, 2023

Experiencing the same issues sadly

@bneumann
Copy link

I thought I saw a PR for this issue. But now I can't seem to find it any more. Did I hallucinate, or is the PR removed?

Nope, I saw it too. Would be cool to have a fix, manually searching the bindings is a pain.

@clrudolphi
Copy link
Contributor

Using SpecFlow's VisualStudio extension version 2022.1.91.26832, which pulls in SpecFlow.NUnit version 3.9.40, I cannot duplicate this problem.
Is there a repro project you can post? I'll take a look to at least try to debug the source of the problem. (Can't promise any solutions until the SpecFlow projects gets back up and running).

@bneumann
Copy link

Hi, I tried these versions without success. But when right clicking on a step and then "Define Steps..." I saw this error:

Warning: AndDiscoveryProviderSucceed: Error during binding discovery.
Command executed:
D:\git\Test_Repo\Output/Debug\net8.0> C:\Program Files\dotnet\dotnet.exe exec c:\users\z001syay\appdata\local\microsoft\visualstudio\17.0_502fdb4c\extensions\qa3k3flr.ote\Connectors\Generic-net7.0\specflow-vs.dll discovery D:\git\Test_Repo\Output/Debug/net8.0\AcceptanceTests.dll ""
Exit code: 4
Message:
System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at System.ModuleHandle.ResolveMethod(QCallModule module, Int32 methodToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount)
at System.ModuleHandle.ResolveMethodHandleInternal(RuntimeModule module, Int32 methodToken, ReadOnlySpan1 typeInstantiationContext, ReadOnlySpan1 methodInstantiationContext)
at System.ModuleHandle.ResolveMethodHandle(Int32 methodToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
at System.RuntimeType.GetMethodBase(RuntimeModule scope, Int32 typeMetadataToken)
at System.Reflection.RuntimeCustomAttributeData..ctor(RuntimeModule scope, MetadataToken caCtorToken, ConstArray& blob)
at System.Reflection.RuntimeCustomAttributeData.GetCustomAttributes(RuntimeModule module, Int32 tkTarget)
at SpecFlowConnector.ReflectionExecutor.Execute(DiscoveryOptions options, Func3 testAssemblyFactory, ILogger _log, IAnalyticsContainer analytics) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\ReflectionExecutor.cs:line 15 at SpecFlowConnector.Runner.ExecuteDiscovery(DiscoveryOptions options, Func3 testAssemblyFactory) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\Runner.cs:line 50
at SpecFlowConnector.Runner.<>c__DisplayClass4_0.b__0(ConnectorOptions options) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\Runner.cs:line 30
at FunctionalExtensions.Map[TSource,TResult](TSource this, Func2 fn) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\NetExtensions\FunctionalExtensions.cs:line 5 at SpecFlowConnector.Runner.Run(String[] args, Func3 testAssemblyFactory) in D:\a\1\s\Connectors\SpecFlow.VisualStudio.SpecFlowConnector.Generic\Runner.cs:line 26
Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: D. Path '', line 0, position 0.
at Newtonsoft.Json.JsonTextReader.ParseValue()
at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at SpecFlow.VisualStudio.Connectors.OutProcSpecFlowConnector.Deserialize(RunProcessResult result, Func`2 formatErrorMessage)
Warning: AndDiscoveryProviderSucceed: The project bindings (e.g. step definitions) could not be discovered. Navigation, step completion and other features are disabled.
Please check the error message above and report to https://github.com/SpecFlowOSS/SpecFlow.VS/issues if you cannot fix.
Warning: ShowProblem: User Notification: All steps have been defined in this file already.

I will try to setup a mini project that I can share. Maybe I can reproduce the error there.

@bneumann
Copy link

Browsing through the code I found that this issue is not specflow in general but the VS integration and the issue is tracked here:
SpecFlowOSS/SpecFlow.VS#145

There is also the missing PR ;) SpecFlowOSS/SpecFlow.VS#146

@gasparnagy
Copy link
Contributor

Until it will be published to the marketplace, you can install this version from the VSIX file attached to the release: https://github.com/SpecFlowOSS/SpecFlow.VS/releases/tag/v2022.1.93-net8

@bneumann
Copy link

Did that and it works like a charme. I think we can close this here?

@dcdraper
Copy link

The new VSIX file works for me too. Thanks @gasparnagy!

@stigc
Copy link

stigc commented Jan 5, 2024

Thanks @gasparnagy

Copy link

github-actions bot commented Feb 5, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

9 participants