Replace the string '' with 'nameof()'

Hi,

I ran into an issue which I believe is a false-positive for the csharpsquid:S2302 rule in SonarCloud

To me, it seems that the engine gets confused by the fact that the literal element is used to refer to a variable (hence the suggestion to use nameof()) but also as a text message for the user (in the form of the exceptions message parameter)

To solve this FP, we had to change the message so that it does not use the word element any more.

1 Like

Hi @norberth ! Thank you for your feedback. You can see an open issue here, that we already have for this rule. Once it gets fixed, it will ignore the message part, once a nameof() call is supplied as a variable name argument.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.