Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RCS1197 does not know about AppendInterpolatedStringHandler #899

Closed
jnyrup opened this issue Apr 29, 2022 · 3 comments · Fixed by #1370
Closed

RCS1197 does not know about AppendInterpolatedStringHandler #899

jnyrup opened this issue Apr 29, 2022 · 3 comments · Fixed by #1370
Assignees

Comments

@jnyrup
Copy link
Contributor

jnyrup commented Apr 29, 2022

Product and Version Used:
v4.1.0

Steps to Reproduce:
C# 10 introduced Improved Interpolated Strings and .NET 6 added an overload StringBuilder.Append(ref AppendInterpolatedStringHandler) which lets you write

new StringBuilder().Append($"13{37}");

and at compile time it is translated into

StringBuilder stringBuilder = new StringBuilder();
StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(2, 1, stringBuilder);
handler.AppendLiteral("13");
handler.AppendFormatted(37);
stringBuilder.Append(ref handler);

SharpLab

image
image

Actual Behavior:
RCS1197 is reported

Expected Behavior:
RCS1197 should not be reported

@fgimian
Copy link

fgimian commented Aug 29, 2022

Confirmed here also, and I think that:

arguments.Append($" CONTENTDIR=\"{destinationPath}\"");

Really does look much clearer than:

arguments.Append(" CONTENTDIR=\"").Append(destinationPath).Append('\"');

😸

@udlose
Copy link

udlose commented Jan 20, 2024

any update on this bug?

@josefpihrt josefpihrt self-assigned this Jan 21, 2024
@josefpihrt
Copy link
Collaborator

Confirmed here also, and I think that:

arguments.Append($" CONTENTDIR=\"{destinationPath}\"");

Really does look much clearer than:

arguments.Append(" CONTENTDIR=\"").Append(destinationPath).Append('\"');

I agree.

Let's remove cases with interpolated string and string concatenation from RCS1197.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants