I have the following method which is covered by passing unit tests;
public static bool TryGetInstance<T>(out T config) where T : class
{
return Instance.TryGetInstance(out config);
}
When I convert this to expression body syntax the unit tests fail?
public static bool TryGetInstance<T>(out T config) where T : class =>
Instance.TryGetInstance(out config);
The failing tests are asserting that the method returns true and that the instance returned for config is not null. I had presumed that these compiled to exactly the same IL?
Why might this be happening?
They are semantically identical, as shown here
the IL is identical:
so: one of two things:
The second option is far more common. Try reverting just this method change, and see if the problem goes away.
If it does: the folks at Microsoft will be interested in a repro.