Verbatim string with interpolation causing false positives with rule C# S2479

Hello,
Verbatim string literals is an exception on rule S2479 but mixed with string interpolation, rule is fired up.

Versions used

  • SonarQube 7.9.1 Developer Edition
  • SonarC# 8.0 (build 9566)
  • SonarScanner MSBuild 4.7.1
  • Azure DevOps Server 17.M153.3

Code sample

// Compliant
string testA = @"
            asasdasd";

// Should be compliant
string testB = $@"asdasdasd
        asasdasd{testA}asdasd
        asdasd";

// Compliant
string testC = @"asdasdasdD
        asasdasd{testA}asdasd
        asdasd";

References
$ - string interpolation
@ - verbatim identifier
C# rule S2479

Could I provide anythings else to help with my issue ?
Thanks,
Alain

2 Likes

thanks @alaincroisetiere for the well written post and great repro

we don’t support C# 8 yet, we’re currently working on it across our dotnet offering

I’ve opened https://github.com/SonarSource/sonar-dotnet/issues/2773 to track it