Closed frankbuckley closed 1 year ago
This appears to be a bug in .NET, not a bug in xUnit.net.
I noticed the reason the process was crashing was a stack overflow, and it was happening in a very strange place in .NET itself (we were calling Assembly.GetTypes()
).
So in an attempt to see if I could isolate the issue away from xUnit.net, I put your code into a standalone console application:
using System;
using System.Numerics;
var value1 = new Int32Value();
var value2 = new Int32Value();
Console.WriteLine($"Value1 == Value2 is {value1 == value2}");
public interface IValue<TSelf, T> : IEquatable<TSelf>, IModulusOperators<TSelf, TSelf, int>
where T : struct, IEquatable<T>, IModulusOperators<T, T, int>
where TSelf : IValue<TSelf, T>
{
T Value { get; }
static int IModulusOperators<TSelf, TSelf, int>.operator %(TSelf left, TSelf right) => left.Value % right.Value;
}
public readonly record struct Int32Value(int Value) : IValue<Int32Value, int>;
Calling dotnet run
on this program causes a simple Fatal error.
message and a process crash. I assume that the .NET startup code is experiencing an issue similar or identical to the stack overflow that we got, but in a layer much earlier (there was no way for me to try/catch around it here).
I don't have any .NET 8 betas installed, so I don't know if the problem is persistent into .NET 8, but I would open a new issue against .NET itself and see if they can track it down and maybe fix it for .NET 8's release later this year.
Here is the repro project I was using: vs376-repro.zip
Thanks - sorry - I should have ruled that out before assuming Xunit had an issue. I will file an issue with .NET runtime.
No worries! It was an easy and interesting deduction. 😄
Given the following:
Running
dotnet test
results in an error: