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

3 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

1 Like

sorry , I now realized that this does not have to do with the new C# 8 feature of allowing @$" ", but the issue stands for the pre-C# 8 syntax of $@" "

2 Likes

this got fixed in SonarCSharp 8.2

1 Like

Do you need to update SonarLint for VisualStudio 2017 ?