Skip to content

Commit

Permalink
React to removal of PlatformAbstractions (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeharder committed Apr 21, 2017
1 parent c82ca4e commit 43426f2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Benchmarks/Middleware/DebugInfoPageMiddleware.cs
@@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Linq;
using System.Runtime;
using System.Threading.Tasks;
Expand All @@ -10,7 +11,6 @@
using Microsoft.AspNetCore.Hosting.Server.Features;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.PlatformAbstractions;

namespace Benchmarks.Middleware
{
Expand All @@ -24,6 +24,14 @@ public class DebugInfoPageMiddleware
private static readonly string _configurationName = "";
#endif

#if NET46
private static readonly string _targetFrameworkName = AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName;
#elif NETCOREAPP2_0
private static readonly string _targetFrameworkName = AppContext.TargetFrameworkName;
#else
#error the target framework needs to be updated.
#endif

private readonly IHostingEnvironment _hostingEnv;
private readonly RequestDelegate _next;
private readonly Scenarios _scenarios;
Expand All @@ -46,7 +54,7 @@ public async Task Invoke(HttpContext httpContext)
await httpContext.Response.WriteAsync("<h2>Configuration Information</h2>");
await httpContext.Response.WriteAsync("<ul>");
await httpContext.Response.WriteAsync($"<li>Environment: {_hostingEnv.EnvironmentName}</li>");
await httpContext.Response.WriteAsync($"<li>Framework: {PlatformServices.Default.Application.RuntimeFramework.FullName}</li>");
await httpContext.Response.WriteAsync($"<li>Framework: {_targetFrameworkName}</li>");
await httpContext.Response.WriteAsync($"<li>Server GC enabled: {GCSettings.IsServerGC}</li>");
await httpContext.Response.WriteAsync($"<li>Configuration: {_configurationName}</li>");
await httpContext.Response.WriteAsync($"<li>Server: {Program.Server}</li>");
Expand Down

0 comments on commit 43426f2

Please sign in to comment.