1
Vote

Recommend string.IsNullOrWhiteSpace() over string.IsNullOrEmpty()

description

IsNullOrWhiteSpace() indicates whether or not a string is null, empty or contains only whitespace characters.
 
Since most required fields will never be just whitespace, and especially in the case of api/secret keys, a check for only whitespace should be made.
 
Currently a user can enter " " which would not throw the appropriate exception.
 
public FBConnectAuthentication(string apiKeyOrAppId, string appSecret)
    {
        if (String.IsNullOrEmpty(apiKeyOrAppId))
        {
            throw new ArgumentException("apiKeyOrAppId cannot be null or empty", "apiKeyOrAppId");
        }
        if (String.IsNullOrEmpty(appSecret))
        {
            throw new ArgumentException("appSecret cannot be null or empty", "appSecret");
        }
 
        this.appSecret = appSecret;
        this.apiKey = apiKeyOrAppId.ToLowerInvariant();
        this.appId = this.apiKey; //the graph api uses the appId not the api key
    }

comments