Here is a simple testcase :
==================================================================
cedric@laptop:~/dev/workspace/boo-svn/tests$ cat interpolation.boo
x = 2
print "TEST 1 (starting with expression)"
print "${x}+2=4"
print "TEST 2 (not starting with expression)"
print "Calculus: ${x}+2=4"
==================================================================
After compiling it with booc, let's run gendarme on the resulting assembly :
===========================================================================
cedric@laptop:~/dev/workspace/boo-svn/tests$ gendarme interpolation.exe
Gendarme v0.0.3.1
Copyright (C) 2005-2006 Novell, Inc. and contributors
/home/cedric/dev/workspace/boo-svn/tests/interpolation.exe - completed (0,150614 seconds).
1 assemblies processed in 0,156524 seconds.
1. UseStringEmptyRule
Problem: The method 'System.Void InterpolationModule::Main(System.String[])' use literal "" instead of String.Empty.
Details:
InterpolationModule::Main:0017: instance of an empty string has been found.
Solution: Change the empty string for String.Empty.
==================================================================================
By disassembling the assembly we see that there is a ldstr "" appended to the stringbuffer when (and only when) the interpolation expression starts with an expression :
===========================================================================
cedric@laptop:~/dev/workspace/boo-svn/tests$ monodis interpolation.exe
(...)
IL_0000: ldc.i4 2
IL_0005: stloc.0
IL_0006: nop
IL_0007: ldstr "TEST 1 (starting with expression)"
IL_000c: call void class [mscorlib]System.Console::WriteLine(string)
IL_0011: nop
IL_0012: newobj instance void class [mscorlib]System.Text.StringBuilder::.ctor()
IL_0017: ldstr ""
IL_001c: call instance class [mscorlib]System.Text.StringBuilder class [mscorlib]System.Text.StringBuilder::Append(string)
IL_0021: ldloc.0
IL_0022: box [mscorlib]System.Int32
IL_0027: call instance class [mscorlib]System.Text.StringBuilder class [mscorlib]System.Text.StringBuilder::Append(object)
Attached a patch who fixes this misbehavior and also optimizes interpolation by instancing the StringBuffer with constructor(string) instead of constructor() when the first expression is a string - thus saving an unnecessary call to Append(string).