From 035ab19f3158cea222e34b3780a9acf5181767b6 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 3 Jul 2020 07:40:17 -0700 Subject: [PATCH] Update PlatformInfo.cs (#23647) * Update PlatformInfo.cs * Simplify ComponentsProfiling initialization --- src/Components/Components/src/PlatformInfo.cs | 2 +- .../Components/src/Profiling/ComponentsProfiling.cs | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/Components/Components/src/PlatformInfo.cs b/src/Components/Components/src/PlatformInfo.cs index 81338cab58..2ed3ace3b9 100644 --- a/src/Components/Components/src/PlatformInfo.cs +++ b/src/Components/Components/src/PlatformInfo.cs @@ -11,7 +11,7 @@ namespace Microsoft.AspNetCore.Components static PlatformInfo() { - IsWebAssembly = RuntimeInformation.IsOSPlatform(OSPlatform.Create("WEBASSEMBLY")); + IsWebAssembly = RuntimeInformation.IsOSPlatform(OSPlatform.Browser); } } } diff --git a/src/Components/Components/src/Profiling/ComponentsProfiling.cs b/src/Components/Components/src/Profiling/ComponentsProfiling.cs index 03e14c8f57..f47a0c917c 100644 --- a/src/Components/Components/src/Profiling/ComponentsProfiling.cs +++ b/src/Components/Components/src/Profiling/ComponentsProfiling.cs @@ -13,14 +13,9 @@ namespace Microsoft.AspNetCore.Components.Profiling // is so that if we later have two different implementations (one for WebAssembly, one for // Server), the execution characteristics of calling Start/End will be unchanged and historical // perf data will still be comparable to newer data. - public static readonly ComponentsProfiling Instance; - - static ComponentsProfiling() - { - Instance = RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")) - ? new WebAssemblyComponentsProfiling() - : (ComponentsProfiling)new NoOpComponentsProfiling(); - } + public static readonly ComponentsProfiling Instance = PlatformInfo.IsWebAssembly + ? new WebAssemblyComponentsProfiling() + : (ComponentsProfiling)new NoOpComponentsProfiling(); public abstract void Start([CallerMemberName] string? name = null); public abstract void End([CallerMemberName] string? name = null);