Open GabrieleMessina opened 1 year ago
In my opinion those methods are still confusing with this PR. Why does "white space" include an empty string, but doesn't include null? Neither are white-space characters. Just from the method name I'd assume that an empty string would fail the Guard.IsWhiteSpace
call.
But I can see how the method name is similar to String.IsNullOrWhiteSpace
, which also includes empty strings. But that method also explicitly mentions empty strings in its documentation.
So, at least I'd suggest to change the documentation of those methods to also mention empty strings.
For even better distinction I would suggest to only allow white-space characters in Guard.IsWhiteSpace
and add additional methods for Guard.IsEmptyOrWhiteSpace
.
@cremor I think you have a point. I'll change the code as soon as I can.
I'm not so sure, though, about the new Guard.IsEmptyOrWhiteSpace
method because it can be achieved using a combination of the other Guard methods and I don't think it'll be widely used.
Closes #441
Fixed Guard IsWhiteSpace and IsNotWhiteSpace methods adding a check for null before calling string.IsNullOrWhiteSpace. Added some tests for both methods.
PR Checklist
Other information
I don't know if this can be considered a breaking change.