Do not report MA0028 for concatenation of constant strings and chars
Merged
ME
2mo ago+34+34+01234567890123456789-1-1-0123456789
Fixes #1528
MA0028 reported sb.Append(" " + Const + " ") where Const is a const char, although the compiler merges this concatenation into a single string. The char operand is an implicit conversion rather than a constant string, and the left side is itself a nested concatenation, so the rule did not recognize it as constant.
Changes:
IsConstStringnow also accepts an implicit conversion of a constantchar, and a string+whose operands are all constant (recursively).- Concatenations that include a non-constant value (e.g.
"a" + 'b' + 10) are still reported. - Added tests and a note in
docs/Rules/MA0028.md.
MA0028 tests pass on Roslyn 5.9 and 4.8.