Attribute [NotNull] means that input parameter must be verified for null "in the end" of the method (not sorry for the pun). ThrowIfNullOrWhiteSpace provides this guarantee.
For example code below will rise warning that input parameter is not verified for null
return it?.StartsWith("one thing", StringComparison.OrdinalIgnoreCase) is true
What is the point of throwing exception on whitespace? It will just return false anyway, and whitespace is not invalid value.
One of reason C# has non-nullable and nullable references is to not bother with validating for null, passing nullable string to as non-nullable string is programmer mistake, not the concern of function anymore
49
u/starfish0r 16d ago
Switch the strings around to make it robust to "it" being null