csharpsquid:S3900 false positive

  • Developer Edition 10.1.0 on-prem

Hello,
the following code is being flagged as csharpsquid:S3900.

public static bool IsMatch(string requestPath)
{
	requestPath ??= String.Empty;
	requestPath = String.Concat(ForwardSlash, requestPath.Trim(ForwardSlash));
	// more code
}

The call “requestPath.Trim” is marked as possible null and needs a validation check before using, but the null coalescing operator ??= does exactly the NULL check and assign a value with String.Empty, if the parameter is null.

Kind regards

2 Likes

Hi @Lutti1988. Thank you for reporting the problem. We have created a Github Issue for it (with currently no estimation of when it will be fixed).

1 Like

I can confirm this is still a problem, and that is not limited to string’s.

Hi @Corniel,

The issue is still Open.

 
HTH,
Ann