This is a migrated thread and some comments may be shown as answers.

Bug when i use "Clean code" -> "Use string.Format() where possible"

1 Answer 35 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Nicko Pekhlivanov
Top achievements
Rank 1
Nicko Pekhlivanov asked on 15 Feb 2012, 01:54 PM
Hello there,


I'm using Version Q1 2012 Internal Build (2012.1.208.4)
i have made the following simple application:

using System;
using System.Linq;
 
 
namespace JustCodeStringFormatBug
{
    class Program
    {
        static void Main(string[] args)
        {
            string stringBeforeJustCode = string.Format("Today is {0}" + ".", "Monday"); // Today is Monday.
            string stringAfterJustCode = string.Format(string.Format("Today is {0}."), "Monday"); // Format Exception          
        }
    }
}


Here i found a bug with "Clean Code" functionality when i have expression like this one:  string.Format("Today is {0}" + ".", "Monday"); 
"Clean Code" makes it looks like string.Format(string.Format("Today is {0}."), "Monday"); , and the problem is that these two expressions are not the same, so i get  FormatException.


I think that this suggestion might be helpful to resolve this bug.


1.  string.Format("Today is {0}" + ".", "Monday"); should look like string.Format(string.Format("Today is {{0}}."), "Monday");


Yordan Todorov





1 Answer, 1 is accepted

Sort by
0
Stefan Avramov
Telerik team
answered on 15 Feb 2012, 03:12 PM
Hi,

Thanks a lot for the report. We fixed that for our next internal release. You receive some Telerik points.

All the best,
Stefan Avramov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
General Discussions
Asked by
Nicko Pekhlivanov
Top achievements
Rank 1
Answers by
Stefan Avramov
Telerik team
Share this question
or