Indeed, CQLinq does not yet have this feature. However, in many cases, you can compensate for the fact that the ICodeElement.Name and IMember.FullName properties for IMethod contain a list of parameter type names separated by a coma. For example, here is the FullName method:
System.Windows.Forms.Control.BeginInvoke(Delegate,Object[])
and here is his Name :
BeginInvoke(Delegate,Object[])
For example, here is a CQLinq rule that uses parameter type names to match event handler methods:
// <Name>Event handler methods should be declared private</Name> warnif count > 0 from m in Application.Methods where !m.IsPrivate && // A method is considered as event handler if... m.NbParameters == 2 && // ...it has two parameters.. m.Name.Contains("Object") && // ...of types Object... m.Name.Contains("EventArgs") && // ...and EventArgs // Discard special cases !m.ParentType.IsDelegate && !m.IsGeneratedByCompiler select new { m,m.Visibility } // This rule implementation relies on the facts that: // -> A method name contains the type of its parameters. // -> All EventArgs derived types have the suffix "EventArgs".
source share