Reporter | Evgeny Morozov (shift_evgeny) |
---|---|
Created | Nov 4, 2016 10:00:03 PM |
Updated | Apr 11, 2018 5:28:43 PM |
Subsystem | Code Analysis - C# |
Assignee | Andrey Dyatlov (Andrey.Dyatlov) |
Priority | Normal |
State | Fixed In Branch |
Type | Feature |
Fix version | No Fix versions |
Affected versions | 2016.2.2 |
Fixed In Version ReSharper | Undefined |
VsVersion | All Versions |
string.Format($"{0}", "my text")
The above code looks fine at first glance, but its return value is "0" - not "my text" as you might expect!
This can be hard for a human to see, but R# can probably detect this easily, since it already detects format strings. Using an interpolated string as a format strings should probably be a warning - it seems much more likely to be a mistake than intentional. (How often do you really need to "double-format" a string?)