Repository: dotnet/runtime
File: src/libraries/Common/tests/WasmTestRunner/WasmTestRunner.cs (C#)

Code before:
using Microsoft.DotNet.XHarness.TestRunners.Common;
using Microsoft.DotNet.XHarness.TestRunners.Xunit;

public class WasmTestRunner : WasmApplicationEntryPoint
{
    protected int MaxParallelThreadsFromArg { get; set; }
    protected override int? MaxParallelThreads => RunInParallel ? MaxParallelThreadsFromArg : base.MaxParallelThreads;

#if TARGET_WASI
    public static int Main(string[] args)
    {
        return PollWasiEventLoopUntilResolved((Thread)null!, MainAsync(args));

        [UnsafeAccessor(UnsafeAccessorKind.StaticMethod, Name = "PollWasiEventLoopUntilResolved")]
        static extern T PollWasiEventLoopUntilResolved<T>(Thread t, Task<T> mainTask);
    }


#else
    public static Task<int> Main(string[] args)
    {
        return MainAsync(args);
    }
#endif

    // workaround for https://github.com/dotnet/runtime/issues/122972
    protected override IEnumerable<TestAssemblyInfo> GetTestAssemblies()
    {
        AssemblyName an = new AssemblyName(Path.GetFileNameWithoutExtension(TestAssembly));
        Assembly assembly = Assembly.Load(an);
        return new[] { new TestAssemblyInfo(assembly, TestAssembly) };
    }

    public static async Task<int> MainAsync(string[] args)
    {
        if (args.Length == 0)
        {
            Console.WriteLine($"No args given");
            return -1;
        }

        var runner = new WasmTestRunner();

        runner.TestAssembly = args[0];

        var excludedTraits = new List<string>();
        var includedTraits = new List<string>();
        var includedNamespaces = new List<string>();
        var includedClasses = new List<string>();
        var includedMethods = new List<string>();
        var untilFailed = false;

Review comment (suggestion):
```suggestion
    // WASM-TODO: workaround for https://github.com/dotnet/runtime/issues/122972
```

Code after:
using Microsoft.DotNet.XHarness.TestRunners.Common;
using Microsoft.DotNet.XHarness.TestRunners.Xunit;

public class WasmTestRunner : WasmApplicationEntryPoint
{
    protected int MaxParallelThreadsFromArg { get; set; }
    protected override int? MaxParallelThreads => RunInParallel ? MaxParallelThreadsFromArg : base.MaxParallelThreads;

#if TARGET_WASI
    public static int Main(string[] args)
    {
        return PollWasiEventLoopUntilResolved((Thread)null!, MainAsync(args));

        [UnsafeAccessor(UnsafeAccessorKind.StaticMethod, Name = "PollWasiEventLoopUntilResolved")]
        static extern T PollWasiEventLoopUntilResolved<T>(Thread t, Task<T> mainTask);
    }


#else
    public static Task<int> Main(string[] args)
    {
        return MainAsync(args);
    }
#endif

    // WASM-TODO: workaround for https://github.com/dotnet/runtime/issues/122972
    protected override IEnumerable<TestAssemblyInfo> GetTestAssemblies()
    {
        AssemblyName an = new AssemblyName(Path.GetFileNameWithoutExtension(TestAssembly));
        Assembly assembly = Assembly.Load(an);
        return new[] { new TestAssemblyInfo(assembly, TestAssembly) };
    }

    public static async Task<int> MainAsync(string[] args)
    {
        if (args.Length == 0)
        {
            Console.WriteLine($"No args given");
            return -1;
        }

        var runner = new WasmTestRunner();

        runner.TestAssembly = args[0];

        var excludedTraits = new List<string>();
        var includedTraits = new List<string>();
        var includedNamespaces = new List<string>();
        var includedClasses = new List<string>();
        var includedMethods = new List<string>();
        var untilFailed = false;