Seems after upgrading from 0.81.7 to 1.2.11 the same instance is no longer used for IClassConstructor and ITestEndEventReceiver. This means that if you implement these these will be called on 2 separate instances which breaks this code:
private AsyncServiceScope _scope;
public Task<object> Create(Type type, ClassConstructorMetadata classConstructorMetadata)
{
_scope = ServiceProvider.CreateAsyncScope();
return Task.FromResult(ActivatorUtilities.GetServiceOrCreateInstance(_scope.ServiceProvider, type));
}
public ValueTask OnTestEnd(TestContext context) => _scope.DisposeAsync(); // This errors with a nullref