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);