I am struggling with a simple NDepend query that should return all methods that are not called by any other method (dead code) but not methods with names like ToString() or ToInt32().
The following query returns method names like ToString(), ToChar() or ToInt32() which should be excluded because their name starts with “To” due to this condition:
&& !m.SimpleName.StartsWith("To*")
// <Name>Methods that are not called</Name>
// <Description>Shows all Methods that could be removed</Description>
from m in JustMyCode.Methods
where m.NbMethodsCallingMe == 0
&& !m.IsConstructor
&& !m.IsAbstract
&& !m.SimpleName.StartsWith("get_")
&& !m.SimpleName.StartsWith("set_")
&& !m.SimpleName.StartsWith("<>f")
&& !m.SimpleName.Contains("callback")
&& !m.SimpleName.Contains("TClient")
&& !m.SimpleName.StartsWith("To*")
&& !m.SimpleName.StartsWith("From*")
&& !m.SimpleName.Contains("Click")
&& m.SimpleName != "BeginInvoke"
&& m.SimpleName != "EndInvoke"
&& m.SimpleName != ".cctor"
select new { m, MethodName = m.SimpleName, Count= m.NbMethodsCallingMe}
What I am missing?