dotnet / dotnet/roslynator

RCS1198: false positive with interpolated strings in .NET 6

Open
#828 4 comments 0 reactions 0 assignees View on GitHub
Area-Analyzers
Dominant language
C#
Stars
3.5k
Forks
294
Avg merge
2h 30m
Merged PRs (30d)
4

Description

**Product and Version Used**:
Microsoft Visual Studio Community 2019 Version 16.10.4
Roslynator.Formatting.Analyzers 1.2.1 via Nuget
[RCS1198](https://github.com/JosefPihrt/Roslynator/blob/master/docs/analyzers/RCS1198.md)
[IDE0071](https://docs.microsoft.com/ru-ru/dotnet/fundamentals/code-analysis/style-rules/ide0071)

**Steps to Reproduce**:
```csharp
enum Foo
{
A = 0
}

var test1 = $"Test foo = {Foo.A}."; // Get diagnostic for RCS1198.
var test2 = $"Test foo = {Foo.A.ToString()}."; // Get diagnostic for IDE0071.
```

**Actual Behavior**:
Get diagnostic for RCS1198 in interpolated strings.

**Expected Behavior**:
No diagnostic for RCS1198 in interpolated strings, because `ToString()` would be implicitly invoked by the compiler.

Contributor guide

Open the contributing guide

Research direction

Start with the linked RCS1198 documentation and reproduce the two interpolated-string examples in the stated Visual Studio and Roslynator setup. Done means the first example no longer receives an RCS1198 diagnostic because interpolation already invokes ToString implicitly.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.