Skip to content

IClassConstructor and ITestEndEventReceiver no longer use the same instance #3939

@Rick-van-Dam

Description

@Rick-van-Dam

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions