Skip to content

Commit 06e7308

Browse files
Remove obsolete preprocessor directives
Remove now-redundant `#if NET...` directives and associated redundant code.
1 parent fa4f98e commit 06e7308

File tree

12 files changed

+10
-62
lines changed

12 files changed

+10
-62
lines changed

src/Shared/JsonExtensions.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,10 @@ internal static class JsonExtensions
77
{
88
private static readonly JsonSerializerOptions Options = new()
99
{
10-
#if NET9_0_OR_GREATER
1110
NewLine = "\n",
12-
#endif
1311
WriteIndented = true,
1412
};
1513

1614
public static string ToJson(this JsonNode value)
17-
{
18-
var json = value.ToJsonString(Options);
19-
20-
#if !NET9_0_OR_GREATER
21-
json = json.Replace("\r\n", "\n");
22-
#endif
23-
24-
return json;
25-
}
15+
=> value.ToJsonString(Options);
2616
}

src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/ApiParameterDescriptionExtensions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,10 @@ internal static bool IsFromForm(this ApiParameterDescription apiParameter)
9090
{
9191
bool isEnhancedModelMetadataSupported = true;
9292

93-
#if NET9_0_OR_GREATER
9493
if (AppContext.TryGetSwitch("Microsoft.AspNetCore.Mvc.ApiExplorer.IsEnhancedModelMetadataSupported", out var isEnabled))
9594
{
9695
isEnhancedModelMetadataSupported = isEnabled;
9796
}
98-
#endif
9997

10098
var source = apiParameter.Source;
10199
var elementType = isEnhancedModelMetadataSupported ? apiParameter.ModelMetadata?.ElementType : null;

src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/SwaggerGenerator.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,11 +1013,7 @@ private OpenApiResponse GenerateResponse(
10131013
string statusCode,
10141014
ApiResponseType apiResponseType)
10151015
{
1016-
string description = null;
1017-
1018-
#if NET10_0_OR_GREATER
1019-
description = apiResponseType.Description;
1020-
#endif
1016+
string description = apiResponseType.Description;
10211017

10221018
if (string.IsNullOrEmpty(description))
10231019
{

test/Swashbuckle.AspNetCore.IntegrationTests/ClientGenerator.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#if NET10_0_OR_GREATER
2-
3-
using System.Diagnostics;
1+
using System.Diagnostics;
42
using System.Reflection;
53
using System.Text;
64
using System.Text.Json;
@@ -368,5 +366,3 @@ static async Task<StringBuilder> ProcessStream(
368366
}
369367
}
370368
}
371-
372-
#endif

test/Swashbuckle.AspNetCore.IntegrationTests/CodeGenerationTests.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#if NET10_0_OR_GREATER
2-
3-
using System.Reflection;
1+
using System.Reflection;
42
using System.Security.Cryptography;
53
using System.Text;
64
using Microsoft.OpenApi;
@@ -118,5 +116,3 @@ private static string GetProjectRoot() =>
118116
.First((p) => p.Key is "ProjectRoot")
119117
.Value!;
120118
}
121-
122-
#endif

test/Swashbuckle.AspNetCore.IntegrationTests/HttpServerFixture.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#if NET10_0_OR_GREATER
2-
using Microsoft.AspNetCore.Mvc.Testing;
1+
using Microsoft.AspNetCore.Mvc.Testing;
32

43
namespace Swashbuckle.AspNetCore.IntegrationTests;
54

@@ -17,4 +16,3 @@ public string ServerUrl
1716
}
1817
}
1918
}
20-
#endif

test/Swashbuckle.AspNetCore.IntegrationTests/KiotaClientTests.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#if NET10_0_OR_GREATER
2-
3-
using Microsoft.AspNetCore.Http;
1+
using Microsoft.AspNetCore.Http;
42
using Microsoft.Kiota.Abstractions.Authentication;
53
using Microsoft.Kiota.Http.HttpClientLibrary;
64
using TodoApp.KiotaClient;
@@ -262,5 +260,3 @@ private static async Task WithTodoAppClientAsync(Func<KiotaTodoApiClient, Task>
262260
await callback(client);
263261
}
264262
}
265-
266-
#endif

test/Swashbuckle.AspNetCore.IntegrationTests/NSwagClientTests.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#if NET10_0_OR_GREATER
2-
3-
using Microsoft.AspNetCore.Http;
1+
using Microsoft.AspNetCore.Http;
42
using TodoApp.NSwagClient;
53

64
namespace Swashbuckle.AspNetCore.IntegrationTests;
@@ -271,5 +269,3 @@ private static async Task WithTodoAppClientAsync(Func<NSwagTodoApiClient, Task>
271269
await callback(client);
272270
}
273271
}
274-
275-
#endif

test/Swashbuckle.AspNetCore.IntegrationTests/PlaywrightFixture.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#if NET10_0_OR_GREATER
2-
using Microsoft.Playwright;
1+
using Microsoft.Playwright;
32

43
namespace Swashbuckle.AspNetCore.IntegrationTests;
54

@@ -60,4 +59,3 @@ private void EnsureInstalled()
6059
}
6160
}
6261
}
63-
#endif

test/Swashbuckle.AspNetCore.IntegrationTests/UITests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#if NET10_0_OR_GREATER
2-
using ReDocApp = ReDoc;
1+
using ReDocApp = ReDoc;
32

43
namespace Swashbuckle.AspNetCore.IntegrationTests;
54

@@ -45,4 +44,3 @@ private sealed class RedocFixture : HttpApplicationFixture<ReDocApp.Program>;
4544

4645
private sealed class SwaggerUIFixture : HttpApplicationFixture<Basic.Startup>;
4746
}
48-
#endif

0 commit comments

Comments
 (0)