1
0
Форкнуть 0

Silence style-cop wrt `String` vs `string`.

This commit is contained in:
J Wyman 2017-08-01 12:46:37 -04:00
Родитель 816d91ebac
Коммит aa0d71bea6
19 изменённых файлов: 74 добавлений и 74 удалений

Просмотреть файл

@ -192,7 +192,7 @@ namespace Atlassian.Bitbucket.Authentication
/// </summary>
private static string GetEncodedCredentials(string user, string password)
{
string authString = String.Format("{0}:{1}", user, password);
string authString = string.Format("{0}:{1}", user, password);
byte[] authBytes = Encoding.UTF8.GetBytes(authString);
string authEncode = Convert.ToBase64String(authBytes);
return authEncode;

Просмотреть файл

@ -19,7 +19,7 @@ namespace Atlassian.Bitbucket.Authentication.BasicAuth
// use the provided username and password and attempt a Basic Auth request to a known
// REST API resource.
string basicAuthValue = String.Format("{0}:{1}", username, password);
string basicAuthValue = string.Format("{0}:{1}", username, password);
byte[] authBytes = Encoding.UTF8.GetBytes(basicAuthValue);
basicAuthValue = Convert.ToBase64String(authBytes);
var authHeader = "Basic " + basicAuthValue;

Просмотреть файл

@ -36,7 +36,7 @@ namespace Atlassian.Bitbucket.Authentication
/// </summary>
public sealed class TokenScope: Microsoft.Alm.Authentication.TokenScope
{
public static readonly TokenScope None = new TokenScope(String.Empty);
public static readonly TokenScope None = new TokenScope(string.Empty);
/// <summary>
/// Access accounts

Просмотреть файл

@ -245,9 +245,9 @@ namespace GitHub.Authentication
public async Task<Credential> NoninteractiveLogonWithCredentials(TargetUri targetUri, string username, string password, string authenticationCode)
{
BaseSecureStore.ValidateTargetUri(targetUri);
if (String.IsNullOrWhiteSpace(username))
if (string.IsNullOrWhiteSpace(username))
throw new ArgumentNullException("username", "The `username` parameter is null or invalid.");
if (String.IsNullOrWhiteSpace(password))
if (string.IsNullOrWhiteSpace(password))
throw new ArgumentNullException("username", "The `password` parameter is null or invalid.");
Credential credentials = null;

Просмотреть файл

@ -86,13 +86,13 @@ namespace GitHub.Authentication
httpClient.DefaultRequestHeaders.Add("User-Agent", Global.UserAgent);
httpClient.DefaultRequestHeaders.Add("Accept", GitHubApiAcceptsHeaderValue);
string basicAuthValue = String.Format("{0}:{1}", username, password);
string basicAuthValue = string.Format("{0}:{1}", username, password);
byte[] authBytes = Encoding.UTF8.GetBytes(basicAuthValue);
basicAuthValue = Convert.ToBase64String(authBytes);
httpClient.DefaultRequestHeaders.Add("Authorization", "Basic " + basicAuthValue);
if (!String.IsNullOrWhiteSpace(authenticationCode))
if (!string.IsNullOrWhiteSpace(authenticationCode))
{
httpClient.DefaultRequestHeaders.Add(GitHubOptHeader, authenticationCode);
}
@ -119,7 +119,7 @@ namespace GitHub.Authentication
scopesBuilder.Append(']');
string jsonContent = String.Format(JsonContentFormat, scopesBuilder, targetUri, Environment.MachineName, DateTime.Now);
string jsonContent = string.Format(JsonContentFormat, scopesBuilder, targetUri, Environment.MachineName, DateTime.Now);
using (StringContent content = new StringContent(jsonContent, Encoding.UTF8, HttpJsonContentType))
using (HttpResponseMessage response = await httpClient.PostAsync(_authorityUrl, content))
@ -155,10 +155,10 @@ namespace GitHub.Authentication
case HttpStatusCode.Unauthorized:
{
if (String.IsNullOrWhiteSpace(authenticationCode)
&& response.Headers.Any(x => String.Equals(GitHubOptHeader, x.Key, StringComparison.OrdinalIgnoreCase)))
if (string.IsNullOrWhiteSpace(authenticationCode)
&& response.Headers.Any(x => string.Equals(GitHubOptHeader, x.Key, StringComparison.OrdinalIgnoreCase)))
{
var mfakvp = response.Headers.First(x => String.Equals(GitHubOptHeader, x.Key, StringComparison.OrdinalIgnoreCase) && x.Value != null && x.Value.Count() > 0);
var mfakvp = response.Headers.First(x => string.Equals(GitHubOptHeader, x.Key, StringComparison.OrdinalIgnoreCase) && x.Value != null && x.Value.Count() > 0);
if (mfakvp.Value.First().Contains("app"))
{
@ -191,7 +191,7 @@ namespace GitHub.Authentication
BaseSecureStore.ValidateTargetUri(targetUri);
BaseSecureStore.ValidateCredential(credentials);
string authString = String.Format("{0}:{1}", credentials.Username, credentials.Password);
string authString = string.Format("{0}:{1}", credentials.Username, credentials.Password);
byte[] authBytes = Encoding.UTF8.GetBytes(authString);
string authEncode = Convert.ToBase64String(authBytes);

Просмотреть файл

@ -76,7 +76,7 @@ namespace GitHub.UI
return g.Value;
throw new ArgumentException(
String.Format(CultureInfo.InvariantCulture, "Unknown Octicon: {0}", icon), nameof(icon));
string.Format(CultureInfo.InvariantCulture, "Unknown Octicon: {0}", icon), nameof(icon));
}
// Initializes the cache dictionary with lazy entries for all available octicons

Просмотреть файл

@ -92,7 +92,7 @@ namespace GitHub.UI
private void SetText(string text)
{
if (String.IsNullOrEmpty(text))
if (string.IsNullOrEmpty(text))
{
foreach (var textBox in TextBoxes)
{
@ -106,7 +106,7 @@ namespace GitHub.UI
{
TextBoxes[i].Text = digits[i].ToString();
}
SetValue(TextProperty, String.Join("", digits));
SetValue(TextProperty, string.Join("", digits));
}
public string Text
@ -175,7 +175,7 @@ namespace GitHub.UI
textBox.TextChanged += (sender, args) =>
{
SetValue(TextProperty, String.Join("", GetTwoFactorCode()));
SetValue(TextProperty, string.Join("", GetTwoFactorCode()));
var change = args.Changes.FirstOrDefault();
args.Handled = (change != null && change.AddedLength > 0) && MoveNext();
};
@ -205,12 +205,12 @@ namespace GitHub.UI
private static string GetTextBoxValue(TextBox textBox)
{
return String.IsNullOrEmpty(textBox.Text) ? " " : textBox.Text;
return string.IsNullOrEmpty(textBox.Text) ? " " : textBox.Text;
}
private string GetTwoFactorCode()
{
return String.Join("", TextBoxes.Select(textBox => textBox.Text));
return string.Join("", TextBoxes.Select(textBox => textBox.Text));
}
}
}

Просмотреть файл

@ -33,7 +33,7 @@ namespace GitHub.Authentication
{
public sealed class TokenScope: Microsoft.Alm.Authentication.TokenScope, IEquatable<TokenScope>
{
public static readonly TokenScope None = new TokenScope(String.Empty);
public static readonly TokenScope None = new TokenScope(string.Empty);
/// <summary>
/// Create gists

Просмотреть файл

@ -126,8 +126,8 @@ namespace Microsoft.Alm.Authentication
string password = passwordLength > 0
? Marshal.PtrToStringUni(credStruct.CredentialBlob, passwordLength / sizeof(char))
: String.Empty;
string username = credStruct.UserName ?? String.Empty;
: string.Empty;
string username = credStruct.UserName ?? string.Empty;
credentials = new Credential(username, password);
@ -289,7 +289,7 @@ namespace Microsoft.Alm.Authentication
{
if (ReferenceEquals(token, null))
throw new ArgumentNullException(nameof(token));
if (String.IsNullOrEmpty(token.Value))
if (string.IsNullOrEmpty(token.Value))
throw new ArgumentException(nameof(token.Value));
}
}

Просмотреть файл

@ -32,7 +32,7 @@ namespace Microsoft.Alm.Authentication
/// </summary>
public sealed class Credential: Secret, IEquatable<Credential>
{
public static readonly Credential Empty = new Credential(String.Empty, String.Empty);
public static readonly Credential Empty = new Credential(string.Empty, string.Empty);
/// <summary>
/// Creates a credential object with a username and password pair.
@ -45,7 +45,7 @@ namespace Microsoft.Alm.Authentication
throw new ArgumentNullException(nameof(username));
this.Username = username;
this.Password = password ?? String.Empty;
this.Password = password ?? string.Empty;
}
/// <summary>
@ -53,7 +53,7 @@ namespace Microsoft.Alm.Authentication
/// </summary>
/// <param name="username">The username value of the <see cref="Credential"/>.</param>
public Credential(string username)
: this(username, String.Empty)
: this(username, string.Empty)
{ }
/// <summary>
@ -111,8 +111,8 @@ namespace Microsoft.Alm.Authentication
if (ReferenceEquals(credential1, null) || ReferenceEquals(null, credential2))
return false;
return String.Equals(credential1.Username, credential2.Username, StringComparison.Ordinal)
&& String.Equals(credential1.Password, credential2.Password, StringComparison.Ordinal);
return string.Equals(credential1.Username, credential2.Username, StringComparison.Ordinal)
&& string.Equals(credential1.Password, credential2.Password, StringComparison.Ordinal);
}
/// <summary>

Просмотреть файл

@ -37,7 +37,7 @@ namespace Microsoft.Alm.Authentication
public SecretCache(string @namespace, Secret.UriNameConversion getTargetName)
{
if (String.IsNullOrWhiteSpace(@namespace))
if (string.IsNullOrWhiteSpace(@namespace))
throw new ArgumentNullException(@namespace);
_namespace = @namespace;

Просмотреть файл

@ -39,7 +39,7 @@ namespace Microsoft.Alm.Authentication
public Token(string value, TokenType type)
{
if (String.IsNullOrWhiteSpace(value))
if (string.IsNullOrWhiteSpace(value))
throw new ArgumentNullException(nameof(value));
Debug.Assert(Enum.IsDefined(typeof(TokenType), type), $"The `{nameof(type)}` parameter is invalid");
@ -50,9 +50,9 @@ namespace Microsoft.Alm.Authentication
public Token(string value, string typeName)
{
if (String.IsNullOrWhiteSpace(value))
if (string.IsNullOrWhiteSpace(value))
throw new ArgumentNullException(nameof(value));
if (String.IsNullOrWhiteSpace(typeName))
if (string.IsNullOrWhiteSpace(typeName))
throw new ArgumentNullException(nameof(typeName));
TokenType type;
@ -126,7 +126,7 @@ namespace Microsoft.Alm.Authentication
public static bool GetTypeFromFriendlyName(string name, out TokenType type)
{
if (String.IsNullOrWhiteSpace(name))
if (string.IsNullOrWhiteSpace(name))
throw new ArgumentNullException(nameof(name));
type = TokenType.Unknown;
@ -138,7 +138,7 @@ namespace Microsoft.Alm.Authentication
string typename;
if (GetFriendlyNameFromType(type, out typename))
{
if (String.Equals(name, typename, StringComparison.OrdinalIgnoreCase))
if (string.Equals(name, typename, StringComparison.OrdinalIgnoreCase))
return true;
}
}
@ -175,7 +175,7 @@ namespace Microsoft.Alm.Authentication
{
if (token == null)
throw new ArgumentNullException(nameof(token));
if (String.IsNullOrWhiteSpace(token.Value))
if (string.IsNullOrWhiteSpace(token.Value))
throw new ArgumentException("Value property returned null or empty.", nameof(token));
if (token.Value.Length > NativeMethods.Credential.PasswordMaxLength)
throw new ArgumentOutOfRangeException(nameof(token));
@ -212,7 +212,7 @@ namespace Microsoft.Alm.Authentication
{
string value = Encoding.UTF8.GetString(bytes, preamble, bytes.Length - preamble);
if (!String.IsNullOrWhiteSpace(value))
if (!string.IsNullOrWhiteSpace(value))
{
token = new Token(value, type);
token.TargetIdentity = targetIdentity;
@ -225,7 +225,7 @@ namespace Microsoft.Alm.Authentication
{
string value = Encoding.UTF8.GetString(bytes);
if (!String.IsNullOrWhiteSpace(value))
if (!string.IsNullOrWhiteSpace(value))
{
token = new Token(value, type);
}
@ -243,7 +243,7 @@ namespace Microsoft.Alm.Authentication
{
if (ReferenceEquals(token, null))
throw new ArgumentNullException(nameof(token));
if (String.IsNullOrWhiteSpace(token.Value))
if (string.IsNullOrWhiteSpace(token.Value))
throw new ArgumentException("Value property returned null or empty.", nameof(token));
bytes = null;

Просмотреть файл

@ -34,7 +34,7 @@ namespace Microsoft.Alm.Authentication
{
protected TokenScope(string value)
{
if (String.IsNullOrWhiteSpace(value))
if (string.IsNullOrWhiteSpace(value))
{
_scopes = new string[0];
}
@ -63,7 +63,7 @@ namespace Microsoft.Alm.Authentication
_scopes = result;
}
public string Value { get { return String.Join(" ", _scopes); } }
public string Value { get { return string.Join(" ", _scopes); } }
protected readonly IReadOnlyList<string> _scopes;

Просмотреть файл

@ -34,7 +34,7 @@ namespace Microsoft.Alm.Authentication
{
internal class WwwAuthenticateHelper
{
public static readonly Credential Credentials = new Credential(String.Empty, String.Empty);
public static readonly Credential Credentials = new Credential(string.Empty, string.Empty);
public static readonly AuthenticationHeaderValue NtlmHeader = new AuthenticationHeaderValue("NTLM");
public static readonly AuthenticationHeaderValue NegotiateHeader = new AuthenticationHeaderValue("Negotiate");

Просмотреть файл

@ -106,7 +106,7 @@ namespace Microsoft.Alm.Git
internal GitInstallation(string path, KnownGitDistribution version)
{
Debug.Assert(!String.IsNullOrWhiteSpace(path), $"The `{nameof(path)}` parameter is null or invalid.");
Debug.Assert(!string.IsNullOrWhiteSpace(path), $"The `{nameof(path)}` parameter is null or invalid.");
Debug.Assert(CommonConfigPaths.ContainsKey(version), $"The `{nameof(version)}` parameter not found in `{nameof(CommonConfigPaths)}`.");
Debug.Assert(CommonCmdPaths.ContainsKey(version), $"The `{nameof(version)}` parameter not found in `{nameof(CommonCmdPaths)}`.");
Debug.Assert(CommonGitPaths.ContainsKey(version), $"The `{nameof(version)}` parameter not found in `{nameof(CommonGitPaths)}`.");
@ -252,7 +252,7 @@ namespace Microsoft.Alm.Git
return StringComparer.OrdinalIgnoreCase.GetHashCode(Path);
}
public override String ToString()
public override string ToString()
{
return Path;
}

Просмотреть файл

@ -139,7 +139,7 @@ namespace Microsoft.Alm.Git
const int SourceColumnMaxWidth = 23;
// source column format is file:line
string source = String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}:{1}", filePath, lineNumber);
string source = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}:{1}", filePath, lineNumber);
if (source.Length > SourceColumnMaxWidth)
{
@ -163,7 +163,7 @@ namespace Microsoft.Alm.Git
}
// Git's trace format is "{timestamp,-15} {source,-23} trace: {details}"
string text = String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:HH:mm:ss.ffffff} {1,-23} trace: [{2}] {3}", DateTime.Now, source, memberName, message);
string text = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:HH:mm:ss.ffffff} {1,-23} trace: [{2}] {3}", DateTime.Now, source, memberName, message);
return text;
}

Просмотреть файл

@ -44,7 +44,7 @@ namespace Microsoft.Alm.Git
/// <returns><see langword="True"/> if succeeds; <see langword="false"/> otherwise.</returns>
static public bool FindApp(string name, out string path)
{
if (!String.IsNullOrWhiteSpace(name))
if (!string.IsNullOrWhiteSpace(name))
{
string pathext = Environment.GetEnvironmentVariable("PATHEXT");
string envpath = Environment.GetEnvironmentVariable("PATH");
@ -54,15 +54,15 @@ namespace Microsoft.Alm.Git
for (int i = 0; i < paths.Length; i++)
{
if (String.IsNullOrWhiteSpace(paths[i]))
if (string.IsNullOrWhiteSpace(paths[i]))
continue;
for (int j = 0; j < exts.Length; j++)
{
if (String.IsNullOrWhiteSpace(exts[j]))
if (string.IsNullOrWhiteSpace(exts[j]))
continue;
string value = String.Format("{0}\\{1}{2}", paths[i], name, exts[j]);
string value = string.Format("{0}\\{1}{2}", paths[i], name, exts[j]);
if (File.Exists(value))
{
value = value.Replace("\\\\", "\\");
@ -100,24 +100,24 @@ namespace Microsoft.Alm.Git
installations = null;
var programFiles32Path = String.Empty;
var programFiles64Path = String.Empty;
var appDataRoamingPath = String.Empty;
var appDataLocalPath = String.Empty;
var programDataPath = String.Empty;
var reg32HklmPath = String.Empty;
var reg64HklmPath = String.Empty;
var reg32HkcuPath = String.Empty;
var reg64HkcuPath = String.Empty;
var shellPathValue = String.Empty;
var programFiles32Path = string.Empty;
var programFiles64Path = string.Empty;
var appDataRoamingPath = string.Empty;
var appDataLocalPath = string.Empty;
var programDataPath = string.Empty;
var reg32HklmPath = string.Empty;
var reg64HklmPath = string.Empty;
var reg32HkcuPath = string.Empty;
var reg64HkcuPath = string.Empty;
var shellPathValue = string.Empty;
using (var reg32HklmKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))
using (var reg32HkcuKey = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry32))
using (var reg32HklmSubKey = reg32HklmKey?.OpenSubKey(GitSubkeyName))
using (var reg32HkcuSubKey = reg32HkcuKey?.OpenSubKey(GitSubkeyName))
{
reg32HklmPath = reg32HklmSubKey?.GetValue(GitValueName, reg32HklmPath) as String;
reg32HkcuPath = reg32HkcuSubKey?.GetValue(GitValueName, reg32HkcuPath) as String;
reg32HklmPath = reg32HklmSubKey?.GetValue(GitValueName, reg32HklmPath) as string;
reg32HkcuPath = reg32HkcuSubKey?.GetValue(GitValueName, reg32HkcuPath) as string;
}
if ((programFiles32Path = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)) != null)
@ -132,8 +132,8 @@ namespace Microsoft.Alm.Git
using (var reg64HklmSubKey = reg64HklmKey?.OpenSubKey(GitSubkeyName))
using (var reg64HkcuSubKey = reg64HkcuKey?.OpenSubKey(GitSubkeyName))
{
reg64HklmPath = reg64HklmSubKey?.GetValue(GitValueName, reg64HklmPath) as String;
reg64HkcuPath = reg64HkcuSubKey?.GetValue(GitValueName, reg64HkcuPath) as String;
reg64HklmPath = reg64HklmSubKey?.GetValue(GitValueName, reg64HklmPath) as string;
reg64HkcuPath = reg64HkcuSubKey?.GetValue(GitValueName, reg64HkcuPath) as string;
}
if ((programFiles64Path = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)) != null)
@ -172,46 +172,46 @@ namespace Microsoft.Alm.Git
candidates.Add(new GitInstallation(shellPathValue, KnownGitDistribution.GitForWindows32v1));
}
if (!String.IsNullOrEmpty(reg64HklmPath))
if (!string.IsNullOrEmpty(reg64HklmPath))
{
candidates.Add(new GitInstallation(reg64HklmPath, KnownGitDistribution.GitForWindows64v2));
}
if (!String.IsNullOrEmpty(programFiles32Path))
if (!string.IsNullOrEmpty(programFiles32Path))
{
candidates.Add(new GitInstallation(programFiles64Path, KnownGitDistribution.GitForWindows64v2));
}
if (!String.IsNullOrEmpty(reg64HkcuPath))
if (!string.IsNullOrEmpty(reg64HkcuPath))
{
candidates.Add(new GitInstallation(reg64HkcuPath, KnownGitDistribution.GitForWindows64v2));
}
if (!String.IsNullOrEmpty(reg32HklmPath))
if (!string.IsNullOrEmpty(reg32HklmPath))
{
candidates.Add(new GitInstallation(reg32HklmPath, KnownGitDistribution.GitForWindows32v2));
candidates.Add(new GitInstallation(reg32HklmPath, KnownGitDistribution.GitForWindows32v1));
}
if (!String.IsNullOrEmpty(programFiles32Path))
if (!string.IsNullOrEmpty(programFiles32Path))
{
candidates.Add(new GitInstallation(programFiles32Path, KnownGitDistribution.GitForWindows32v2));
candidates.Add(new GitInstallation(programFiles32Path, KnownGitDistribution.GitForWindows32v1));
}
if (!String.IsNullOrEmpty(reg32HkcuPath))
if (!string.IsNullOrEmpty(reg32HkcuPath))
{
candidates.Add(new GitInstallation(reg32HkcuPath, KnownGitDistribution.GitForWindows32v2));
candidates.Add(new GitInstallation(reg32HkcuPath, KnownGitDistribution.GitForWindows32v1));
}
if (!String.IsNullOrEmpty(programDataPath))
if (!string.IsNullOrEmpty(programDataPath))
{
candidates.Add(new GitInstallation(programDataPath, KnownGitDistribution.GitForWindows64v2));
candidates.Add(new GitInstallation(programDataPath, KnownGitDistribution.GitForWindows32v2));
candidates.Add(new GitInstallation(programDataPath, KnownGitDistribution.GitForWindows32v1));
}
if (!String.IsNullOrEmpty(appDataLocalPath))
if (!string.IsNullOrEmpty(appDataLocalPath))
{
candidates.Add(new GitInstallation(appDataLocalPath, KnownGitDistribution.GitForWindows64v2));
candidates.Add(new GitInstallation(appDataLocalPath, KnownGitDistribution.GitForWindows32v2));
candidates.Add(new GitInstallation(appDataLocalPath, KnownGitDistribution.GitForWindows32v1));
}
if (!String.IsNullOrEmpty(appDataRoamingPath))
if (!string.IsNullOrEmpty(appDataRoamingPath))
{
candidates.Add(new GitInstallation(appDataRoamingPath, KnownGitDistribution.GitForWindows64v2));
candidates.Add(new GitInstallation(appDataRoamingPath, KnownGitDistribution.GitForWindows32v2));
@ -311,7 +311,7 @@ namespace Microsoft.Alm.Git
const string GitFolderName = ".git";
const string LocalConfigFileName = "config";
if (!String.IsNullOrWhiteSpace(startingDirectory))
if (!string.IsNullOrWhiteSpace(startingDirectory))
{
var dir = new DirectoryInfo(startingDirectory);

Просмотреть файл

@ -90,7 +90,7 @@ namespace Microsoft.Alm.Authentication
value = Encoding.UTF8.GetString(data);
TokenType tokenType;
if (String.Equals(type, "Federated", StringComparison.OrdinalIgnoreCase))
if (string.Equals(type, "Federated", StringComparison.OrdinalIgnoreCase))
{
tokenType = TokenType.Federated;
}

Просмотреть файл

@ -32,7 +32,7 @@ namespace Microsoft.Alm.Authentication
{
public class VstsTokenScope: TokenScope
{
public static readonly VstsTokenScope None = new VstsTokenScope(String.Empty);
public static readonly VstsTokenScope None = new VstsTokenScope(string.Empty);
/// <summary>
/// Grants the ability to access build artifacts, including build results, definitions, and