History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: RSRP-42689
Type: New Feature New Feature
Status: Open Open
Priority: Normal Normal
Assignee: Ilya Ryzhenkov
Reporter: Niels Ull Harremoës
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
ReSharper

"Use format string" should have option not to replace string constants

Created: 08 Jun 07 16:50   Updated: 08 Jun 07 16:53
Component/s: Context actions
Fix Version/s: Future Versions
Security Level: Everybody (All jira users)

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown

Build: 451


 Description  « Hide
We have code like:
imgHtml = 
   @"<img style=""cursor:hand"" title=""" + toolTip +   @""" onclick=""launchConfirmDeleteFileVersionDlg(" + version.Id + 
      @", '" + SysUtils.JSEncode(HtmlEncode(version.FileName)) + @"')"" src=""" + IconPath.Delete16 + @""">";

where IconPath.Delete16 is a public const string

Applying "Use string format" gives

imgHtml = 
   string.Format(@"<img style=""cursor:hand"" title=""{0}"" onclick=""launchConfirmDeleteFileVersionDlg({1}, '{2}')"" src=""{3}"">", 
         toolTip, version.Id, SysUtils.JSEncode(HtmlEncode(version.FileName)), IconPath.Delete16);

I would much prefer

imgHtml = 
   string.Format(@"<img style=""cursor:hand"" title=""{0}"" onclick=""launchConfirmDeleteFileVersionDlg({1}, '{2}')"" src=""" + 
      IconPath.Delete16 + @""">", 
      toolTip, version.Id, SysUtils.JSEncode(HtmlEncode(version.FileName)));

since the runtime can compute the static string at load time anyway, and it makes it clearer what can actually vary.

This would probably be a configurable option.



 All   Comments   Work Log   Change History      Sort Order:
There are no comments yet on this issue.