Skip to content

Commit

Permalink
feat!: remove .NET Core 3.1 support from MockHttpServer since it is E…
Browse files Browse the repository at this point in the history
…OL for a long time now.
  • Loading branch information
skwasjer committed Oct 1, 2024
1 parent ea2dfb7 commit 86f820e
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 43 deletions.
2 changes: 1 addition & 1 deletion src/MockHttp.Server/MockHttp.Server.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net6.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
<PackageId>skwas.MockHttp.Server</PackageId>
<AssemblyName>skwas.MockHttp.Server</AssemblyName>
<RootNamespace>MockHttp</RootNamespace>
Expand Down
8 changes: 2 additions & 6 deletions src/MockHttp.Server/Server/HttpResponseMessageExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,11 @@ internal static async Task MapToFeatureAsync
responseFeature.ReasonPhrase = response.ReasonPhrase;

CopyHeaders(response.Headers, responseFeature.Headers);
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
if (response.Content is not null)
{
CopyHeaders(response.Content.Headers, responseFeature.Headers);
Stream contentStream = await response.Content.ReadAsStreamAsync(
#if NET6_0_OR_GREATER
cancellationToken
#endif
).ConfigureAwait(false);
Stream contentStream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
await using ConfiguredAsyncDisposable _ = contentStream.ConfigureAwait(false);
await contentStream.CopyToAsync(responseBodyFeature.Writer.AsStream(), 4096, cancellationToken).ConfigureAwait(false);
}
Expand Down
15 changes: 9 additions & 6 deletions src/MockHttp.Server/Server/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ internal static partial class Log
{
internal const string LogRequestMessageTemplate = "Connection id \"{ConnectionId}\", Request id \"{RequestId}\": {Message}";

#if NET6_0_OR_GREATER
[LoggerMessage(
EventId = 0,
Level = LogLevel.Debug,
Message = LogRequestMessageTemplate)]
private static partial void LogDebugRequestMessage(ILogger logger, string connectionId, string requestId, string message, Exception? exception);
#else
private static readonly Action<ILogger, string, string, string, Exception?> LogDebugRequestMessage = LoggerMessage.Define<string, string, string>(LogLevel.Debug, new EventId(0), LogRequestMessageTemplate);
#endif
Message = LogRequestMessageTemplate
)]
private static partial void LogDebugRequestMessage(
ILogger logger,
string connectionId,
string requestId,
string message,
Exception? exception
);

public static void LogRequestMessage(this ILogger logger, HttpContext httpContext, string message, Exception? exception = null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/MockHttp.Server/Server/WrappedHttpRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public WrappedHttpRequest(HttpRequest request)

RequestUri = uriBuilder.Uri;

// ReSharper disable once ConditionIsAlwaysTrueOrFalse
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
if (request.Body is not null)
{
Content = new StreamContent(request.Body)
Expand Down
2 changes: 0 additions & 2 deletions test/MockHttp.Server.Tests/Fixtures/LoggerFactoryFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ protected LoggerFactoryFixture(Action<ILoggingBuilder>? configure = null)
builder
.AddDebug()
#if NET6_0_OR_GREATER
.AddSimpleConsole(opts => opts.IncludeScopes = true)
#endif
;
configure?.Invoke(builder);
Expand Down
2 changes: 1 addition & 1 deletion test/MockHttp.Server.Tests/MockHttp.Server.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net6.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>

<IsTestProject>true</IsTestProject>

Expand Down
2 changes: 1 addition & 1 deletion test/MockHttp.Server.Tests/MockHttpServerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public async Task When_using_other_API_like_webRequest_it_should_respond_correct
request.ContentType = MediaTypes.PlainText;
await using (Stream requestStream = await request.GetRequestStreamAsync())
{
requestStream.Write(Encoding.ASCII.GetBytes("request-content"));
await requestStream.WriteAsync(Encoding.ASCII.GetBytes("request-content"));
}

// Assert
Expand Down
25 changes: 0 additions & 25 deletions test/MockHttp.Server.Tests/PublicApi/.NET_Core_3.1.verified.txt

This file was deleted.

0 comments on commit 86f820e

Please sign in to comment.