Skip to content

Discovering step definitions raises error Method not found: 'Void System.Text.Json.JsonSerializerOptions.set_Encoder #88

@harryKont

Description

@harryKont

Used Visual Studio

Visual Studio 2022

Are the latest Visual Studio updates installed?

Yes

Content of reqnroll.json (if present)

No response

Issue Description

When loading/building a Reqnroll tests project the following error is raised in output and the steps are not discovered

Info: OnActivityStarted: Starting Visual Studio Extension...
Info: CreateProjectScope: Initializing project: OrderAutomation.Api.SystemTests
Info: OnSettingsInitialized: Project settings initialized: .NETCoreApp,Version=v8.0,Reqnroll:2.4.0
Warning: AndDiscoveryProviderSucceed: Error during binding discovery. 
Command executed:
  C:\src\order-automation-system\OrderAutomationService\src\OrderAutomation.Api.SystemTests\bin\Debug\net8.0> C:\Program Files\dotnet\dotnet.exe exec c:\users\user\appdata\local\microsoft\visualstudio\17.0_7ddf514c\extensions\h2qrjthr.ahg\Connectors\Reqnroll-Generic-net8.0\reqnroll-vs.dll discovery C:\src\order-automation-system\OrderAutomationService\src\OrderAutomation.Api.SystemTests\bin\Debug\net8.0\OrderAutomation.Api.SystemTests.dll ""
Exit code: 0
Message: 
'M' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
Method not found: 'Void System.Text.Json.JsonSerializerOptions.set_Encoder(System.Text.Encodings.Web.JavaScriptEncoder)'.
Unable to deserialize discovery options:  Method not found: 'Void System.Text.Json.JsonSerializerOptions.set_Encoder(System.Text.Encodings.Web.JavaScriptEncoder)'. ({
  "assemblyFile": "C:\\src\\order-automation-system\\OrderAutomationService\\src\\OrderAutomation.Api.SystemTests\\bin\\Debug\\net8.0\\OrderAutomation.Api.SystemTests.dll",
  "connectorFolder": "c:\\users\\user\\appdata\\local\\microsoft\\visualstudio\\17.0_7ddf514c\\extensions\\h2qrjthr.ahg\\Connectors\\Reqnroll-Generic-net8.0"
})
Error System.MissingMethodException: Method not found: 'Void System.Text.Json.JsonSerializerOptions.set_Encoder(System.Text.Encodings.Web.JavaScriptEncoder)'.
   at ReqnrollConnector.JsonSerialization.GetJsonSerializerSettings()
   at ReqnrollConnector.JsonSerialization.DeserializeDiscoveryOptions(String json, ILogger log) in D:\a\Reqnroll.VisualStudio\Reqnroll.VisualStudio\Connectors\Reqnroll.VisualStudio.ReqnrollConnector.Generic\JsonSerialization.cs:line 77

DiscoveryOptions { DebugMode = False, AssemblyFile = C:\src\order-automation-system\OrderAutomationService\src\OrderAutomation.Api.SystemTests\bin\Debug\net8.0\OrderAutomation.Api.SystemTests.dll, ConfigFile = , ConnectorFolder = c:\users\user\appdata\local\microsoft\visualstudio\17.0_7ddf514c\extensions\h2qrjthr.ahg\Connectors\Reqnroll-Generic-net8.0 }
Loading C:\src\order-automation-system\OrderAutomationService\src\OrderAutomation.Api.SystemTests\bin\Debug\net8.0\OrderAutomation.Api.SystemTests.dll
OrderAutomation.Api.SystemTests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null loaded
Microsoft.Extensions.DependencyModel.DependencyContext loaded
Loading System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Loading nunit.framework, Version=3.13.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb
Resolved with Microsoft.Extensions.DependencyModel.Resolution.AppBaseCompilationAssemblyResolver from C:\src\order-automation-system\OrderAutomationService\src\OrderAutomation.Api.SystemTests\bin\Debug\net8.0\nunit.framework.dll
Found runtime library:nunit.framework, Version=3.13.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb
Loading netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
System.InvalidOperationException: Cannot find reference assembly 'netstandard.dll' file for package netstandard
   at Microsoft.Extensions.DependencyModel.Resolution.ReferenceAssemblyPathResolver.TryResolveAssemblyPaths(CompilationLibrary library, List`1 assemblies)
   at ReqnrollConnector.AssemblyLoading.RuntimeCompositeCompilationAssemblyResolver.TryResolveAssemblyPaths(CompilationLibrary library, List`1 assemblies) in D:\a\Reqnroll.VisualStudio\Reqnroll.VisualStudio\Connectors\Reqnroll.VisualStudio.ReqnrollConnector.Generic\AssemblyLoading\RuntimeCompositeCompilationAssemblyResolver.cs:line 19
Loading Microsoft.Extensions.Configuration.UserSecrets, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
Resolved with Microsoft.Extensions.DependencyModel.Resolution.PackageCompilationAssemblyResolver from C:\Users\user\.nuget\packages\Microsoft.Extensions.Configuration.UserSecrets\8.0.1\lib/net8.0/Microsoft.Extensions.Configuration.UserSecrets.dll
Found runtime library:Microsoft.Extensions.Configuration.UserSecrets, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
Loading System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Loading System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Loading System.Runtime.Loader, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Loading System.Collections.Immutable, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Loading System.Text.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
Loading System.Text.Encodings.Web, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
Resolved with Microsoft.Extensions.DependencyModel.Resolution.AppBaseCompilationAssemblyResolver from C:\src\order-automation-system\OrderAutomationService\src\OrderAutomation.Api.SystemTests\bin\Debug\net8.0\System.Text.Encodings.Web.dll
Found runtime library:System.Text.Encodings.Web, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
Loading System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Loading Reqnroll.VisualStudio.ReqnrollConnector.Models, Version=2025.1.0.0, Culture=neutral, PublicKeyToken=611ce36403091019
System.Text.Json.JsonException: 'M' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
 ---> System.Text.Json.JsonReaderException: 'M' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0.
   at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
   at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker)
   at System.Text.Json.Utf8JsonReader.ReadFirstToken(Byte first)
   at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
   at System.Text.Json.Utf8JsonReader.Read()
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   --- End of inner exception stack trace ---
   at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, 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, JsonSerializerOptions options)
   at ReqnrollConnector.JsonSerialization.DeserializeObjectRunnerResult(String json, ILogger log) in D:\a\Reqnroll.VisualStudio\Reqnroll.VisualStudio\Connectors\Reqnroll.VisualStudio.ReqnrollConnector.Generic\JsonSerialization.cs:line 108
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/reqnroll/Reqnroll.VisualStudio/issues if you cannot fix.

Steps to Reproduce

  1. Create a .NET project targeting .NET8
  2. Add a feature
  3. Build the project
  4. Try to navigate to a step definition from the feature file.

Link to a project repository that reproduces the issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    out of scopeThe issue is not related to our product

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions