Skip to content

Commit

Permalink
Include runtime check for .NET 3.
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminsampica authored and skwasjer committed Mar 24, 2023
1 parent 6448126 commit 2665891
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/MockHttp/Responses/TimeoutBehavior.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace MockHttp.Responses;
using System.Runtime.InteropServices;

namespace MockHttp.Responses;

internal sealed class TimeoutBehavior
: IResponseBehavior
Expand Down Expand Up @@ -26,8 +28,10 @@ public Task HandleAsync(MockHttpRequestContext requestContext, HttpResponseMessa
.ContinueWith(_ =>
{
var tcs = new TaskCompletionSource<HttpResponseMessage>();
#if NET5_0_OR_GREATER
if (!cancellationToken.IsCancellationRequested)
#if (NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER)
bool isNetCore3 = RuntimeInformation.FrameworkDescription.StartsWith(".NET Core 3", StringComparison.OrdinalIgnoreCase); // Shim for .NET 5 being EOL and no longer producing an assembly for it.

if (!cancellationToken.IsCancellationRequested && !isNetCore3)
{
tcs.TrySetException(new TaskCanceledException(null, new TimeoutException()));
}
Expand Down

0 comments on commit 2665891

Please sign in to comment.