From 95efba01333903fb2eba7db067ee847cb8d704ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Thierry=20K=C3=A9chichian?= Date: Fri, 24 Nov 2023 04:41:34 +0100 Subject: [PATCH] Remove compiler directives (#14739) --- .../Configuration/GithubHandler.cs | 10 ++-------- .../TenantJsonConfigurationProvider.cs | 13 ------------- .../Security/ApiAuthenticationHandler.cs | 13 ------------- .../Extensions/ServiceCollectionExtensions.cs | 6 ------ .../Modules/Overrides/HttpClient/ValueStopwatch.cs | 10 ---------- 5 files changed, 2 insertions(+), 50 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.GitHub/Configuration/GithubHandler.cs b/src/OrchardCore.Modules/OrchardCore.GitHub/Configuration/GithubHandler.cs index 36ae88fa571..78f0f3fff2a 100644 --- a/src/OrchardCore.Modules/OrchardCore.GitHub/Configuration/GithubHandler.cs +++ b/src/OrchardCore.Modules/OrchardCore.GitHub/Configuration/GithubHandler.cs @@ -16,16 +16,10 @@ namespace OrchardCore.GitHub.Configuration { public class GitHubHandler : OAuthHandler { - -#if !NET8_0_OR_GREATER - public GitHubHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) - : base(options, logger, encoder, clock) - { } -#else public GitHubHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder) : base(options, logger, encoder) - { } -#endif + { + } protected override async Task CreateTicketAsync(ClaimsIdentity identity, AuthenticationProperties properties, OAuthTokenResponse tokens) { diff --git a/src/OrchardCore/OrchardCore.Abstractions/Modules/Overrides/Configuration/TenantJsonConfigurationProvider.cs b/src/OrchardCore/OrchardCore.Abstractions/Modules/Overrides/Configuration/TenantJsonConfigurationProvider.cs index bc82e686dc8..fa5c5fd7b54 100644 --- a/src/OrchardCore/OrchardCore.Abstractions/Modules/Overrides/Configuration/TenantJsonConfigurationProvider.cs +++ b/src/OrchardCore/OrchardCore.Abstractions/Modules/Overrides/Configuration/TenantJsonConfigurationProvider.cs @@ -1,4 +1,3 @@ -using System; using System.IO; using OrchardCore.Environment.Shell.Configuration.Internal; @@ -20,17 +19,5 @@ public TenantJsonConfigurationProvider(TenantJsonConfigurationSource source) : b /// /// The stream to read. public override void Load(Stream stream) => Data = JsonConfigurationParser.Parse(stream); - -#if !NET8_0_OR_GREATER - /// - /// Dispose the provider. - /// - /// true if invoked from . - protected override void Dispose(bool disposing) - { - base.Dispose(true); - (Source.FileProvider as IDisposable)?.Dispose(); - } -#endif } } diff --git a/src/OrchardCore/OrchardCore.Infrastructure/Security/ApiAuthenticationHandler.cs b/src/OrchardCore/OrchardCore.Infrastructure/Security/ApiAuthenticationHandler.cs index 263dbdde03b..e0ea44c392e 100644 --- a/src/OrchardCore/OrchardCore.Infrastructure/Security/ApiAuthenticationHandler.cs +++ b/src/OrchardCore/OrchardCore.Infrastructure/Security/ApiAuthenticationHandler.cs @@ -15,18 +15,6 @@ public class ApiAuthenticationHandler : AuthenticationHandler _authenticationOptions; -#if !NET8_0_OR_GREATER - public ApiAuthenticationHandler( - IOptions authenticationOptions, - IOptionsMonitor options, - ILoggerFactory logger, - UrlEncoder encoder, - ISystemClock clock) - : base(options, logger, encoder, clock) - { - _authenticationOptions = authenticationOptions; - } -#else public ApiAuthenticationHandler( IOptions authenticationOptions, IOptionsMonitor options, @@ -36,7 +24,6 @@ public ApiAuthenticationHandler( { _authenticationOptions = authenticationOptions; } -#endif protected override Task HandleAuthenticateAsync() { diff --git a/src/OrchardCore/OrchardCore/Modules/Extensions/ServiceCollectionExtensions.cs b/src/OrchardCore/OrchardCore/Modules/Extensions/ServiceCollectionExtensions.cs index 9889b6a1348..062580b6f07 100644 --- a/src/OrchardCore/OrchardCore/Modules/Extensions/ServiceCollectionExtensions.cs +++ b/src/OrchardCore/OrchardCore/Modules/Extensions/ServiceCollectionExtensions.cs @@ -64,7 +64,6 @@ public static class ServiceCollectionExtensions .Select(sd => sd.GetImplementationType())) .ToArray(); -#if NET8_0_OR_GREATER /// /// Metrics singletons used to isolate tenants from the host. /// @@ -73,7 +72,6 @@ public static class ServiceCollectionExtensions .Where(sd => sd.Lifetime == ServiceLifetime.Singleton) .Select(sd => sd.GetImplementationType()) .ToArray(); -#endif /// /// Adds OrchardCore services to the host service collection. @@ -101,9 +99,7 @@ public static OrchardCoreBuilder AddOrchardCore(this IServiceCollection services AddExtensionServices(builder); AddStaticFiles(builder); -#if NET8_0_OR_GREATER AddMetrics(builder); -#endif AddRouting(builder); IsolateHttpClient(builder); AddEndpointsApiExplorer(builder); @@ -285,7 +281,6 @@ private static void AddStaticFiles(OrchardCoreBuilder builder) }); } -#if NET8_0_OR_GREATER /// /// Adds isolated tenant level metrics services. /// @@ -313,7 +308,6 @@ sd is ClonedSingletonDescriptor && }, order: int.MinValue + 100); } -#endif /// /// Adds isolated tenant level routing services. diff --git a/src/OrchardCore/OrchardCore/Modules/Overrides/HttpClient/ValueStopwatch.cs b/src/OrchardCore/OrchardCore/Modules/Overrides/HttpClient/ValueStopwatch.cs index 19341f36099..78b73bf24e5 100644 --- a/src/OrchardCore/OrchardCore/Modules/Overrides/HttpClient/ValueStopwatch.cs +++ b/src/OrchardCore/OrchardCore/Modules/Overrides/HttpClient/ValueStopwatch.cs @@ -8,10 +8,6 @@ namespace Microsoft.Extensions.Internal; internal readonly struct ValueStopwatch { -#if !NET7_0_OR_GREATER - private static readonly double TimestampToTicks = TimeSpan.TicksPerSecond / (double)Stopwatch.Frequency; -#endif - private readonly long _startTimestamp; public readonly bool IsActive => _startTimestamp != 0; @@ -34,12 +30,6 @@ public TimeSpan GetElapsedTime() var end = Stopwatch.GetTimestamp(); -#if !NET7_0_OR_GREATER - var timestampDelta = end - _startTimestamp; - var ticks = (long)(TimestampToTicks * timestampDelta); - return new TimeSpan(ticks); -#else return Stopwatch.GetElapsedTime(_startTimestamp, end); -#endif } }