S3900 does not consider `string.IsNullOrWhitespace()` as a parameter check

The last three statements all report S3900 despite the values being inspected for null prior to being used.

public static string MyFunc(string arg1, string arg2, string arg3)

	if (string.IsNullOrWhiteSpace(arg1) == true)
		throw new ArgumentNullException(nameof(arg1));

	if (string.IsNullOrWhiteSpace(arg2) == true)
		 throw new ArgumentNullException(nameof(arg2));

	if (string.IsNullOrWhiteSpace(arg3) == true)
		 throw new ArgumentNullException(nameof(arg3));

	var val1  = Encoding.UTF8.GetBytes(arg2.Substring(0, 32));
	var val2 = Encoding.UTF8.GetBytes(arg3.Substring(0, 16));
	var val3 = arg1.Replace('*', '/').Replace(' ', '+');
1 Like

Hi @StingyJack

Thank you for your feedback!
There is an existing issue for False Positives for string.IsNullOrEmpty for rule S3900.
I added the string.IsNullOrWhiteSpace() case to that issue. You can track the progress there.

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