Fody/Anotar — pull request #14 by distantcam (2013-06-18 10:31:30+00:00)
Title: Better NLog IL generation

Detecting the following cases:

Log.Info("somestring");
Log.Info("somestring", new object[0]);
Log.Info("somestring {0}", 1);

This should reduce the amount of extra IL that Anotar adds.

Also, reusing the temporary variables created for complex examples, and better IL changes this:

public void DoLog(object[] args)
{
string text = "Debug";
text = "Method: 'System.Void ClassWithMultipleLoggings::DoLog(System.Object[])'. Line: ~16. " + text;
ClassWithMultipleLoggings.AnotarLogger.Debug(text, args);
string text2 = "Info";
text2 = "Method: 'System.Void ClassWithMultipleLoggings::DoLog(System.Object[])'. Line: ~17. " + text2;
ClassWithMultipleLoggings.AnotarLogger.Info(text2, args);
string text3 = "Warn";
text3 = "Method: 'System.Void ClassWithMultipleLoggings::DoLog(System.Object[])'. Line: ~18. " + text3;
ClassWithMultipleLoggings.AnotarLogger.Warn(text3, args);
}

to this:

public void DoLog(object[] args)
{
string str = "Debug";
ClassWithMultipleLoggings.AnotarLogger.Debug("Method: 'System.Void ClassWithMultipleLoggings::DoLog(System.Object[])'. Line: ~16. " + str, args);
str = "Info";
ClassWithMultipleLoggings.AnotarLogger.Info("Method: 'System.Void ClassWithMultipleLoggings::DoLog(System.Object[])'. Line: ~17. " + str, args);
str = "Warn";
ClassWithMultipleLoggings.AnotarLogger.Warn("Method: 'System.Void ClassWithMultipleLoggings::DoLog(System.Object[])'. Line: ~18. " + str, args);
}