richardszalay/mockhttp

Lib cannot be used in .NET7 projects

obriankevin11 opened this issue · 3 comments

MockHttp 7.0.0 and later are compiled for .NET 6, .NET 5, .NET Standard 2.0, .NET Standard 1.1
=> Why not .NET7? (is it because of issue below?)

I cloned the repo and set
<TargetFrameworks>net7.0</TargetFrameworks>
then used the release lib to my .NET7 project but same issue persists as with the original:

I compared logs with v6.0 (which works fine) and I have infinite "polling on remoteEndPoint" lines with v7.0..

TpTrace Verbose: 0 : 2728, 10, 2023/10/25, 09:53:02.947, 1744473414809, testhost.dll, TestRunCache: OnNewTestResult: Notified the onCacheHit callback.
TpTrace Verbose: 0 : 2728, 7, 2023/10/25, 09:53:03.420, 1744478150272, testhost.dll, TcpClientExtensions.MessageLoopAsync: Polling on remoteEndPoint: [::ffff:127.0.0.1]:52138 localEndPoint: [::ffff:127.0.0.1]:52139
TpTrace Verbose: 0 : 2728, 7, 2023/10/25, 09:53:04.432, 1744488270940, testhost.dll, TcpClientExtensions.MessageLoopAsync: Polling on remoteEndPoint: [::ffff:127.0.0.1]:52138 localEndPoint: [::ffff:127.0.0.1]:52139
TpTrace Verbose: 0 : 2728, 7, 2023/10/25, 09:53:05.439, 1744498342125, testhost.dll, TcpClientExtensions.MessageLoopAsync: Polling on remoteEndPoint: [::ffff:127.0.0.1]:52138 localEndPoint: [::ffff:127.0.0.1]:52139
[...]

So I guess building the lib using .NET7 is not sufficient.

Thank you in advance for your help

Libraries compiled for .net 6 can be used in .net 7. I'll typically only target newer .net versions if there's a feature that's not available in earlier versions.

In the latest release I targetted:

  • .net 5 because it added support for synchronous HttpClient methods that couldn't be mocked otherwise
  • .net 6 because .net 5 has a limited support life

As for the issue you're experiencing, it's not entirely clear what the problem is or how you are using MockHttp - you show TCP tracing logs but the entire point of MockHttp is to stub requests without the need for actual network traffic.

Could you create a small, self-contained, project with a failing unit test so I can better understand the issue?

Hi,
I will attempt to provide the project you're requesting.
Logs I provided are the verbose output of vs2022 default test runner (Logging level: Trace (Includes Platform logs)). I tried to find some differences between v6 and v7. Tests are running in full autonomy and don't require network traffic.
image

I've validated .NET 7 compatibility by running the MockHttp unit tests while consuming the 7.0.0 NuGet package (rather than the local source project) and it all ran fine, so I don't think there should be any issues with .NET 7.

I'm going to close this ticket for now, but feel free to re-open it if you put together a minimal repro.