-
Notifications
You must be signed in to change notification settings - Fork 11
FL0007
Bradley Grainger edited this page Feb 16, 2019
·
1 revision
JavaScript template literals use ${variable}
inside the string to interpolate a variable. C# interpolated strings use $"...{variable}..."
.
Because of the similarity, programmers who use both languages may mistakenly write $"...${variable}..."
, which "works", but adds an extra dollar sign into the content of the string.
This analyzer prohibits the use of $
at the end of an interpolated string segment (which might be immediately before a variable).
var widgets = $"${key} is ${value}"; // BAD
var widgets = $"{key} is {value}"; // GOOD
var price = $"${amount:f2}"; // disallowed
var price = $"{amount:C}"; //workaround: use formatting to insert a currency symbol