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

Improve "Use String.Format"

1 Answer 36 Views
Refactorings
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Matthias Bibo
Top achievements
Rank 1
Matthias Bibo asked on 25 Nov 2013, 09:39 AM
Hello,

the the quick fix "Use String.Format" is very nice, but not very intelligent. Please improve the feature, that is really usable.

Here is a sample:

Is:
message = @"Es wurden " + (e.Result.ResultCount - e.Result.ErrorCount) + @" von " + e.Result.ResultCount + " Dokumenten erfolgreich generiert.\n";

JustCode refactoring:
message = string.Format("{0}{1}{2}{3} Dokumenten erfolgreich generiert.\n", @"Es wurden ", e.Result.ResultCount - e.Result.ErrorCount, @" von ", e.Result.ResultCount);

Excpected refactoring:
message = string.Format(@"Es wurden {0} von {1} Dokumenten erfolgreich generiert.\n",(e.Result.ResultCount - e.Result.ErrorCount), e.Result.ResultCount);

Regards,
Matthias

1 Answer, 1 is accepted

Sort by
0
Accepted
Zdravko
Telerik team
answered on 26 Nov 2013, 01:42 PM
Hi Matthias,

Thanks for your feedback.
Indeed, the @ sign influences the expected output from the JustCode command, even though the output string from the string.Format  remains right.

Just a note, your expected result won't display the new line "\n" and maybe this is the reason we arrange the string this way.

I will log this for further investigation and fixing.
Thanks for sharing it with us.

Regards,
Zdravko
Telerik
Share what you think about JustCode with us, so we can help you even better! You can use the built-in feedback tool inside JustCode, our forum, or our JustCode feedback portal.
Tags
Refactorings
Asked by
Matthias Bibo
Top achievements
Rank 1
Answers by
Zdravko
Telerik team
Share this question
or