Skip to content

Constraints on ServiceCollectionServiceExtensions.Add*<TService, TImplementation>() is too restrictive #2828

@Mardoxx

Description

@Mardoxx

The following will not compile because currently TService is required to be a class

    public interface ITestService
    {
    }

    public class TestService : ITestService
    {
    }

    public static IServiceCollection RegisterScopedTestService<TService, TImplementation>(this IServiceCollection services)
        where TImplementation : class, TService
    {
        return services.AddScoped<TService, TImplementation>();
    }

Was this intentional?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions