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

RCS1214 Incorrect for Interpolation Handlers #1497

Closed
EmmaJaneBonestell opened this issue Aug 10, 2024 · 0 comments · Fixed by #1500
Closed

RCS1214 Incorrect for Interpolation Handlers #1497

EmmaJaneBonestell opened this issue Aug 10, 2024 · 0 comments · Fixed by #1500
Assignees

Comments

@EmmaJaneBonestell
Copy link

Product and Version Used:
Roslynator.Analyzera 4.12.4

Steps to Reproduce:

using System.Globalization;

public void foo()
{
    Span<char> bar = stackalloc char[6];
    bar.TryWrite(CultureInfo.InvariantInfo, $"foobar", out _);
}

Actual Behavior:
$"foobar" is marked by RCS1214 as an unnecessary interpolation.
Accepting the code fix and removing the interpolation causes an error:

bar.TryWrite(CultureInfo.InvariantInfo, "foobar", out _);

Expected Behavior:
RCS1214 should not apply to interpolation handler parameters, e.g. this ref TryWriteInterpolatedStringHandler.
Probably simpler just not to recommend it here, but it could also suggest a codefix to do something like "foobar".TryCopyTo(bar); instead.

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.

2 participants