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
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type of field 'Xunit.ConsoleClient.ConsoleRunner:completionMessages' (3) due to: Could not load file or assembly 'xunit.runner.utility.netcoreapp10, Version=2.4.2.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c' or one of its dependencies.
namespace Xunit.ConsoleClient
{
public class Program
{
[STAThread]
public static int Main(string[] args)
{
Console.OutputEncoding = Encoding.UTF8;
// This code must not contain any references to code in any external assembly (or any code that references any code in any
// other assembly) until AFTER the creation of the AssemblyHelper.
var consoleLock = new object();
var internalDiagnosticsMessageSink = DiagnosticMessageSink.ForInternalDiagnostics(consoleLock, args.Contains("-internaldiagnostics"), args.Contains("-nocolor"));
using (AssemblyHelper.SubscribeResolveForAssembly(typeof(Program), internalDiagnosticsMessageSink))
return new ConsoleRunner(consoleLock).EntryPoint(args);
}
}
}
When Mono JIT compiles Main(), it encounters a call to new ConsoleRunner() . Unlike CoreCLR, Mono JIT attempts to resolve all field types of ConsoleRunner at JIT compilation time, rather than deferring resolution until runtime.
The problem arises because some fields inside ConsoleRunner depend on assemblies that are only resolvable via the assembly resolve event handler. However, this resolve handler is only installed after Main() has been compiled and execution starts. As a result, Mono JIT fails when it attempts to load these types too early, leading to runtime errors.
This would be a workaround for the mono JIT's limitation
We don't officially support Mono w/ xUnit.net v2. Additionally, there are no plans for any further v2 releases.
You're welcome to submit a PR and we will leave it open in the event that there is another v2 release, but this would not meet the bar to issue a new release, since Mono isn't officially supported.
on Mono SDK,
the runtime test's fails with the above error.
see for details: dotnet/runtime#60550
TL;DR:
https://github.com/xunit/xunit/blob/v2/src/xunit.console/Program.cs
When Mono JIT compiles Main(), it encounters a call to new ConsoleRunner() . Unlike CoreCLR, Mono JIT attempts to resolve all field types of ConsoleRunner at JIT compilation time, rather than deferring resolution until runtime.
The problem arises because some fields inside ConsoleRunner depend on assemblies that are only resolvable via the assembly resolve event handler. However, this resolve handler is only installed after Main() has been compiled and execution starts. As a result, Mono JIT fails when it attempts to load these types too early, leading to runtime errors.
This would be a workaround for the mono JIT's limitation
I have provided a similar fix in dotnet/arcade: dotnet/arcade#15467
I think having a similar fix in xunit.v2 would be a good idea as well, I would like to know your thoughts on this?
The text was updated successfully, but these errors were encountered: