Skip to content

Commit 035ab19

Browse files
authored
Update PlatformInfo.cs (#23647)
* Update PlatformInfo.cs * Simplify ComponentsProfiling initialization
1 parent 64c143c commit 035ab19

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src/Components/Components/src/PlatformInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ internal static class PlatformInfo
1111

1212
static PlatformInfo()
1313
{
14-
IsWebAssembly = RuntimeInformation.IsOSPlatform(OSPlatform.Create("WEBASSEMBLY"));
14+
IsWebAssembly = RuntimeInformation.IsOSPlatform(OSPlatform.Browser);
1515
}
1616
}
1717
}

src/Components/Components/src/Profiling/ComponentsProfiling.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,9 @@ internal abstract class ComponentsProfiling
1313
// is so that if we later have two different implementations (one for WebAssembly, one for
1414
// Server), the execution characteristics of calling Start/End will be unchanged and historical
1515
// perf data will still be comparable to newer data.
16-
public static readonly ComponentsProfiling Instance;
17-
18-
static ComponentsProfiling()
19-
{
20-
Instance = RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER"))
21-
? new WebAssemblyComponentsProfiling()
22-
: (ComponentsProfiling)new NoOpComponentsProfiling();
23-
}
16+
public static readonly ComponentsProfiling Instance = PlatformInfo.IsWebAssembly
17+
? new WebAssemblyComponentsProfiling()
18+
: (ComponentsProfiling)new NoOpComponentsProfiling();
2419

2520
public abstract void Start([CallerMemberName] string? name = null);
2621
public abstract void End([CallerMemberName] string? name = null);

0 commit comments

Comments
 (0)