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

Thread is closed for posting
2 posts, 0 answers
  1. Veselin Gerginov
    Veselin Gerginov avatar
    2 posts
    Member since:
    Jul 2006

    Posted 15 Feb 2012 Link to this post

    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

  2. Stefan Avramov
    Stefan Avramov avatar
    41 posts

    Posted 15 Feb 2012 Link to this post


    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 >>
Back to Top