I have an interface with a generic parameter, where the only use of the parameter is that it is substituted in the declaration of its inner implementations. But SonarLint still indicates the above error (“S2326: T is not used in the interface.”) as if the parameter was not used.
public interface Type<T> { // this T is necessary
public static final class Int extends Type<Integer> { /*...*/ }
public static final class String extends Type<String> { /*...*/ }
}
I have a similar issue when creating a generic entity repository
public interface IEntityRepository<T> : IEntityRepository where T : DbContext
{
}
the only purpose of T is to indicate which DbContext to use, which will only be used in the concrete class constructor to set the DB context.
public class EntityRepository<T> : EntityRepository, IEntityRepository<T> where T : DbContext
{
public EntityRepository(T context)
: base(context)
{
}
}