log4net Template for CodeRush

If you use log4net for logging in the traditional way you end up having a lot of classes with the following line:

Private Shared mLog As log4net.ILog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)

This is the VB version of the recommendation from the log4net FAQ (see the section, “How do I get the fully-qualified name of a class in a static block?”).

In order to tell CodeRush, “whenever I type l4n and then a space, fill in the above text,” I created a new CodeRush template for l4n with the above text.  I used the following condition:

(InType and OnEmptyLine) but not (InComment or InMethod or InProperty or InString)

This entry was posted in CodeMinder, CodeRush. Bookmark the permalink.