Update PlatformInfo.cs (#23647)

* Update PlatformInfo.cs
* Simplify ComponentsProfiling initialization
This commit is contained in:
Pranav K 2020-07-03 07:40:17 -07:00 committed by GitHub
parent 64c143cd9c
commit 035ab19f31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 9 deletions

View File

@ -11,7 +11,7 @@ namespace Microsoft.AspNetCore.Components
static PlatformInfo()
{
IsWebAssembly = RuntimeInformation.IsOSPlatform(OSPlatform.Create("WEBASSEMBLY"));
IsWebAssembly = RuntimeInformation.IsOSPlatform(OSPlatform.Browser);
}
}
}

View File

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