I have an extension method like
public static void RemoveDetail<TMaster, TChild>(this TMaster master, TChild child)
where TMaster : class, IMaster<TChild>
where TChild : class, IDetail<TMaster>;
And I have two classes
public class Principal : IMaster<Permission>
{
public virtual IEnumerable<Permission> Permissions { get; }
}
and
public class Permission : IDetail<Principal>
I call RemoveDetail from an Action accepted by method public static void Foreach<T>(this IEnumerable<T> source, Action<T> action);
:
aPrincipal.Permissions.Foreach(x => aPrincipal.RemoveDetail(x));
ReSharper suggest me to replace this call with method group like
aPrincipal.Permissions.Foreach(aPrincipal.RemoveDetail);
This worked fine in VS2013 and previous but it fails on compilation in VS2015 with
'Principal' does not contain a definition for 'RemoveDetail' and no extension method 'RemoveDetail' accepting a first argument of type 'Principal' could be found (are you missing a using directive or an assembly reference?)
Anyone has a suggestion? Do I have to update all of the usages and make ReSharper to avoid this replacement?
List<T>.ForEach
. What is the type ofz
? Are you sure you aren't missing a reference or astatic
keyword somewhere? – Bloodmobile