@DouglasDRF commented on Thu Jan 03 2019
public class List : ICollection, IEnumerable, IEnumerable, IList, IReadOnlyCollection, IReadOnlyList, ICollection, IList
public interface IList : ICollection, IEnumerable, IEnumerable
IList only have Remove() and RemoveAt()... Wouldn't be more interesting put the RemoveAll() method signature in IList for access it?? Neither ICollection or IEnumerable has these methods signatures. Because if I want to remove all items under a specific condition through IList interface I have to transform to a List first
// Enderecos is IList type
var listEnderecos = clienteModel.Enderecos.ToList();
listEnderecos.RemoveAll(p => p == null);
clienteModel.Enderecos = listEnderecos;
With RemoveAll() method in IList
// Enderecos is IList type
clienteModel.Enderecos.RemoveAll(p => p == null);
Adding methods to interfaces is breaking change. It was more explained here: https://github.com/dotnet/core/issues/2199
@douglasdrf this would be a reasonable thing to add as soon as we have default interface implementations
When that feature is in, it would make sense to reopen this request ... we will need to establish our API review position too though.
Default interface implementations won't help. IList needs to be compatible with .NET Standard, and .NET standard includes platforms that will probably never get default interface implementations such as .NET Framework.
@Grauenwolf See https://github.com/dotnet/standard/pull/1019. It looks like .NET Standard 2.1 will require default interface implementations (and so won't be compatible with .Net Framework 4.8).
Why not just offer it as an extension method in the LINQ namespace? We already do this with .Count().