Sonar-dotnet: S3928 FP nameof(this.*)

Created on 16 Jul 2019  路  3Comments  路  Source: SonarSource/sonar-dotnet

Description

I observed a false positive for rule 3928.

Repro steps

Consider the following property:

   private string input;
   public string Request
   {
      get => this.input;
      set => this.input = value ?? throw new ArgumentNullException(nameof(this.Request));
   }

Expected behavior

No warning

Actual behavior

S3928 violation is reported by Sonar

Known workarounds

  • Related information

  • SonarC# Version 7.15 (build 8572)

  • (Visual Studio Version 16.1.6)
  • MS Build 15.9.21+g9802d43bc3
  • Scanner for MSBuild Version: 4.6.2

All 3 comments

thanks @Khaos66 . It will work if you pass nameof(value) - the actual parameter name is value, not Request. And I guess this is what a receiver of ArgumentException would expect, right?

I also wonder, why do you think this is right behaviour?

Yes. My bad!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ohadschn picture ohadschn  路  3Comments

rjgotten picture rjgotten  路  5Comments

SasikumarJonnadula picture SasikumarJonnadula  路  4Comments

duncanp-sonar picture duncanp-sonar  路  5Comments

dougheeren picture dougheeren  路  4Comments