Skip to content

Tests that read Environment.StackTrace don't work on WASM #39223

@akoeplinger

Description

@akoeplinger

It is empty, causing these tests to fail:


  • System.Tests.EnvironmentStackTrace.StackTraceDoesNotStartWithInternalFrame
    fails with System.NullReferenceException.

Failure Message:

[FAIL] System.Tests.EnvironmentStackTrace.StackTraceDoesNotStartWithInternalFrame
System.NullReferenceException : Object reference not set to an instance of an object.
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

Calling Code:

public void StackTraceDoesNotStartWithInternalFrame()
        {
             string stackTrace = Environment.StackTrace;

             // Find first line of the stacktrace and verify that it is Environment.get_StackTrace itself, not an internal frame
             string firstFrame = new StringReader(stackTrace).ReadLine();

             Assert.True(firstFrame.IndexOf("System.Environment.get_StackTrace()") != -1);
        }

For Browser WASM, Environment.StackTrace is empty, which leads to a null return in StringReader.cs's method ReadLine. Therefore, it cannot access IndexOf.


  • System.Diagnostics.TraceSourceTests.TraceEventCacheClassTests.CallstackTest_NotEmpty
    Assert.NotEmpty() Failure
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

  • System.Diagnostics.TraceSourceTests.TraceEventCacheClassTests.CallstackTest_ContainsExpectedFrames
    Assert.Contains() Failure
    Not found: System.Environment.get_StackTrace()

  • System.Diagnostics.TraceSourceTests.TraceListenerClassTests.WriteFooterTest_Callstack
    Assert.Contains() Failure
    Not found: WriteFooterTest_Callstack

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions