Code Generation – Declare Interface
June 29th, 2011
The Declare Interface code provider generates a new definition of an interface and adds interface referenced members to it, if any. The declaring provider is available on an undeclared type reference, that starts with an upper-case letter I, e.g. ILogger.
For example, declaring an Interface from the ILogger reference in this code:
class Log { private static ILogger logger = new Logger(); public static void SendMessage(string msg) { logger.SendMessage(msg); } public static string GetMessage(int index) { return logger.GetMessage(index); } }
Will result in the following Interface declaration:
public interface ILogger { void GetMessage(int index); void SendMessage(string msg); }
The interface declaration is placed above the current type in the same file, and the marker is dropped at the source starting position over the interface reference.
—– Products: CodeRush Pro, CodeRush Xpress Versions: 11.1 and up VS IDEs: any Updated: Jun/30/2011 ID: C107