Reporter | Martin Bischoff (tinu44) |
---|---|
Created | Feb 1, 2011 4:44:52 PM |
Updated | Jan 13, 2012 8:16:48 PM |
Resolved | Jan 13, 2012 3:50:24 PM |
Priority | Normal |
Type | Feature |
Fix versions | 6.0 |
State | Fixed |
Assignee | Ilya Ryzhenkov (orangy) |
Subsystem | Code Analysis |
Affected versions | 5.1.1 |
Fixed in build | 6.5.1.2259 |
One thing I would like to see in ReSharper (and which would have saved me some hours of debugging) would be a warning or error when string.Replace() or other string-methods are called but the result is not assigned.
E.g. I have seen code like this several time, where the author thought string.Replace() would modify the string instance:
As written above, the same warning should also be shown for other string methods, like Delete(), Trim(), etc which return a new string instance with the modifications.
E.g. I have seen code like this several time, where the author thought string.Replace() would modify the string instance:
string myString = ...; // the following line should give a warning: myString.Replace("abc", "xyz"); // probably the author meant this: myString = myString.Replace("abc", "xyz");
As written above, the same warning should also be shown for other string methods, like Delete(), Trim(), etc which return a new string instance with the modifications.