Skip to content

Commit

Permalink
Remove compiler directives (#14739)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtkech authored Nov 24, 2023
1 parent 61ec4cf commit 95efba0
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,10 @@ namespace OrchardCore.GitHub.Configuration
{
public class GitHubHandler : OAuthHandler<GitHubOptions>
{

#if !NET8_0_OR_GREATER
public GitHubHandler(IOptionsMonitor<GitHubOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock)
: base(options, logger, encoder, clock)
{ }
#else
public GitHubHandler(IOptionsMonitor<GitHubOptions> options, ILoggerFactory logger, UrlEncoder encoder)
: base(options, logger, encoder)
{ }
#endif
{
}

protected override async Task<AuthenticationTicket> CreateTicketAsync(ClaimsIdentity identity, AuthenticationProperties properties, OAuthTokenResponse tokens)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.IO;
using OrchardCore.Environment.Shell.Configuration.Internal;

Expand All @@ -20,17 +19,5 @@ public TenantJsonConfigurationProvider(TenantJsonConfigurationSource source) : b
/// </summary>
/// <param name="stream">The stream to read.</param>
public override void Load(Stream stream) => Data = JsonConfigurationParser.Parse(stream);

#if !NET8_0_OR_GREATER
/// <summary>
/// Dispose the provider.
/// </summary>
/// <param name="disposing"><c>true</c> if invoked from <see cref="IDisposable.Dispose"/>.</param>
protected override void Dispose(bool disposing)
{
base.Dispose(true);
(Source.FileProvider as IDisposable)?.Dispose();
}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,6 @@ public class ApiAuthenticationHandler : AuthenticationHandler<ApiAuthorizationOp
{
private readonly IOptions<AuthenticationOptions> _authenticationOptions;

#if !NET8_0_OR_GREATER
public ApiAuthenticationHandler(
IOptions<AuthenticationOptions> authenticationOptions,
IOptionsMonitor<ApiAuthorizationOptions> options,
ILoggerFactory logger,
UrlEncoder encoder,
ISystemClock clock)
: base(options, logger, encoder, clock)
{
_authenticationOptions = authenticationOptions;
}
#else
public ApiAuthenticationHandler(
IOptions<AuthenticationOptions> authenticationOptions,
IOptionsMonitor<ApiAuthorizationOptions> options,
Expand All @@ -36,7 +24,6 @@ public ApiAuthenticationHandler(
{
_authenticationOptions = authenticationOptions;
}
#endif

protected override Task<AuthenticateResult> HandleAuthenticateAsync()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public static class ServiceCollectionExtensions
.Select(sd => sd.GetImplementationType()))
.ToArray();

#if NET8_0_OR_GREATER
/// <summary>
/// Metrics singletons used to isolate tenants from the host.
/// </summary>
Expand All @@ -73,7 +72,6 @@ public static class ServiceCollectionExtensions
.Where(sd => sd.Lifetime == ServiceLifetime.Singleton)
.Select(sd => sd.GetImplementationType())
.ToArray();
#endif

/// <summary>
/// Adds OrchardCore services to the host service collection.
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -285,7 +281,6 @@ private static void AddStaticFiles(OrchardCoreBuilder builder)
});
}

#if NET8_0_OR_GREATER
/// <summary>
/// Adds isolated tenant level metrics services.
/// </summary>
Expand Down Expand Up @@ -313,7 +308,6 @@ sd is ClonedSingletonDescriptor &&
},
order: int.MinValue + 100);
}
#endif

/// <summary>
/// Adds isolated tenant level routing services.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
}
}

0 comments on commit 95efba0

Please sign in to comment.