You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If this library is used on the browser-wasm runtime, any attempt to use the EqtTrace class fails with a System.TypeInitializationException.
This occurs because the PlatformEqtTrace attempts to fetch the process id in its startup. It anticipates that Process.GetCurrentProcess() might throw an InvalidOperationException. However on browser-wasm, that API throws a PlatformNotSupportedException, which does not get handled, resulting in the static constructor failing.
This makes it impossible to use, for example, the MSTest framework on browser-wasm, because that depends on EqtTrace.
Steps to reproduce
I ran into this when trying to use the MSTestDiscoverer in the MSTest test adapter directly. (The test runner doesn't work in browser-wasm for other reasons so it never gets as far as attempting test discovery, which is why I was trying to use this type directly. But assuming the MS Test runner does at some point resolve the problems stopping it getting this far, it will then run into this.)
where the types of the final three arguments are all just empty implementations of the required interfaces.
This call fails with this stack:
System.TypeInitializationException: The type initializer for 'Microsoft.VisualStudio.TestPlatform.ObjectModel.EqtTrace' threw an exception.
---> System.TypeInitializationException: The type initializer for 'Microsoft.VisualStudio.TestPlatform.ObjectModel.PlatformEqtTrace' threw an exception.
---> System.PlatformNotSupportedException: System.Diagnostics.Process is not supported on this platform.
at System.Diagnostics.Process.GetCurrentProcess()
at Microsoft.VisualStudio.TestPlatform.ObjectModel.PlatformEqtTrace.GetProcessId() in /_/src/Microsoft.TestPlatform.PlatformAbstractions/common/Tracing/PlatformEqtTrace.cs:line 429
at Microsoft.VisualStudio.TestPlatform.ObjectModel.PlatformEqtTrace..cctor() in /_/src/Microsoft.TestPlatform.PlatformAbstractions/common/Tracing/PlatformEqtTrace.cs:line 83
--- End of inner exception stack trace ---
at Microsoft.VisualStudio.TestPlatform.ObjectModel.EqtTrace..cctor() in /_/src/Microsoft.TestPlatform.CoreUtilities/Tracing/EqtTrace.cs:line 28
--- End of inner exception stack trace ---
at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.AdapterTraceLogger.LogWarning(String format, Object[] args) in /_/src/Adapter/MSTestAdapter.PlatformServices/Services/TraceLogger.cs:line 39
at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Discovery.AssemblyEnumeratorWrapper.GetTests(String assemblyFileName, IRunSettings runSettings, ICollection`1& warnings) in /_/src/Adapter/MSTest.TestAdapter/Discovery/AssemblyEnumeratorWrapper.cs:line 93
at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.UnitTestDiscoverer.DiscoverTestsInSource(String source, IMessageLogger logger, ITestCaseDiscoverySink discoverySink, IDiscoveryContext discoveryContext) in /_/src/Adapter/MSTest.TestAdapter/Discovery/UnitTestDiscoverer.cs:line 61
at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.UnitTestDiscoverer.DiscoverTests(IEnumerable`1 sources, IMessageLogger logger, ITestCaseDiscoverySink discoverySink, IDiscoveryContext discoveryContext) in /_/src/Adapter/MSTest.TestAdapter/Discovery/UnitTestDiscoverer.cs:line 44
at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.MSTestDiscoverer.DiscoverTests(IEnumerable`1 sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) in /_/src/Adapter/MSTest.TestAdapter/VSTestAdapter/MSTestDiscoverer.cs:line 37
Expected behavior
The logging component should deal gracefully with the fact that process ids are not a thing in this particular runtime, so it should not crash.
Actual behavior
It crashes.
Diagnostic logs
See stack trace in repo.
Environment
.NET 8.0.1, SDK 8.0.101. Running browser-wasm in Edge, so I'm not sure the OS matters all that much, but it's Windows 10 22H2 19045.3930. MSTest.TestAdapter 3.2.0.
The text was updated successfully, but these errors were encountered:
Let's start by fixing it for the mstest runner in the testfx issue above. I think we have a much higher chance of getting it working there. And it seems like a better fit for your workload.
Description
If this library is used on the
browser-wasm
runtime, any attempt to use theEqtTrace
class fails with aSystem.TypeInitializationException
.This occurs because the
PlatformEqtTrace
attempts to fetch the process id in its startup. It anticipates thatProcess.GetCurrentProcess()
might throw anInvalidOperationException
. However onbrowser-wasm
, that API throws aPlatformNotSupportedException
, which does not get handled, resulting in the static constructor failing.This makes it impossible to use, for example, the MSTest framework on
browser-wasm
, because that depends onEqtTrace
.Steps to reproduce
I ran into this when trying to use the
MSTestDiscoverer
in the MSTest test adapter directly. (The test runner doesn't work inbrowser-wasm
for other reasons so it never gets as far as attempting test discovery, which is why I was trying to use this type directly. But assuming the MS Test runner does at some point resolve the problems stopping it getting this far, it will then run into this.)I ran the following code:
where the types of the final three arguments are all just empty implementations of the required interfaces.
This call fails with this stack:
Expected behavior
The logging component should deal gracefully with the fact that process ids are not a thing in this particular runtime, so it should not crash.
Actual behavior
It crashes.
Diagnostic logs
See stack trace in repo.
Environment
.NET 8.0.1, SDK 8.0.101. Running
browser-wasm
in Edge, so I'm not sure the OS matters all that much, but it's Windows 10 22H2 19045.3930. MSTest.TestAdapter 3.2.0.The text was updated successfully, but these errors were encountered: