Hey there,
I just got a code smell reported for a parameter that is in use. But SC thinks I can remove it (“Remove this parameter ‘serviceProvider’, whose value is ignored in the method.”).
I suspect SC has some detection issue due to the parameter’s method used as a method group. Or am I missing sth here?
private static IEnumerable<DbContext> GetAllDbContextInstances(IServiceProvider
serviceProvider)
{
var types = GetAllDbContextTypes();
var instances = types.Select(serviceProvider.GetRequiredService);
foreach (var instance in instances)
{
yield return (DbContext)instance;
}
}
David