Closed
Description
When calling .AddJsonApi()
combined with assembly scanning, it discards and overwrites any prior open-generic registrations.
Example:
// Startup.ConfigureServices
services.AddScoped(typeof(IResourceRepository<,>), typeof(CustomJsonApiRepository<,>));
services.AddScoped(typeof(IResourceReadRepository<,>), typeof(CustomJsonApiRepository<,>));
services.AddScoped(typeof(IResourceWriteRepository<,>), typeof(CustomJsonApiRepository<,>));
services.AddJsonApi<AppDbContext>(discovery: facade => facade.AddCurrentAssembly());
// ArticleRepository.cs
public class ArticleRepository : CustomJsonApiRepository<Article, Guid> { ... }
will add the next registration:
services.AddScoped<IResourceReadRepository<Article, Guid>, EntityFrameworkCoreRepository<Article, Guid>>();
instead of the expected:
services.AddScoped<IResourceReadRepository<Article, Guid>, CustomJsonApiRepository<Article, Guid>>();
Because of this, it is impossible to combine assembly scanning with replaced open-generic registrations.