Skip to content

Commit

Permalink
Address all IDE0049. Use language keywords instead of framework type …
Browse files Browse the repository at this point in the history
…names for type references. (#8613)
  • Loading branch information
IEvangelist authored Sep 1, 2023
1 parent c68d1fd commit 7bd86bf
Show file tree
Hide file tree
Showing 51 changed files with 84 additions and 84 deletions.
6 changes: 3 additions & 3 deletions src/AdoNet/Shared/Storage/DbConnectionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal static class DbConnectionFactory

private static CachedFactory GetFactory(string invariantName)
{
if (String.IsNullOrWhiteSpace(invariantName))
if (string.IsNullOrWhiteSpace(invariantName))
{
throw new ArgumentNullException(nameof(invariantName));
}
Expand Down Expand Up @@ -99,12 +99,12 @@ void AddException(Exception ex)

public static DbConnection CreateConnection(string invariantName, string connectionString)
{
if (String.IsNullOrWhiteSpace(invariantName))
if (string.IsNullOrWhiteSpace(invariantName))
{
throw new ArgumentNullException(nameof(invariantName));
}

if (String.IsNullOrWhiteSpace(connectionString))
if (string.IsNullOrWhiteSpace(connectionString))
{
throw new ArgumentNullException(nameof(connectionString));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void Intercept(IDbCommand command)
//we map these to DbType.Int32
if (commandParameter.DbType == DbType.Boolean)
{
commandParameter.Value = commandParameter.ToString() == Boolean.TrueString ? 1 : 0;
commandParameter.Value = commandParameter.ToString() == bool.TrueString ? 1 : 0;
commandParameter.DbType = DbType.Int32;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ private static MembershipEntry Parse(SiloInstanceTableEntry tableEntry)
}

if (suspectingSilos.Count != suspectingTimes.Count)
throw new OrleansException(String.Format("SuspectingSilos.Length of {0} as read from Azure table is not equal to SuspectingTimes.Length of {1}", suspectingSilos.Count, suspectingTimes.Count));
throw new OrleansException(string.Format("SuspectingSilos.Length of {0} as read from Azure table is not equal to SuspectingTimes.Length of {1}", suspectingSilos.Count, suspectingTimes.Count));

for (int i = 0; i < suspectingSilos.Count; i++)
parse.AddSuspector(suspectingSilos[i], suspectingTimes[i]);
Expand Down Expand Up @@ -326,8 +326,8 @@ private static SiloInstanceTableEntry Convert(MembershipEntry memEntry, string d
}
else
{
tableEntry.SuspectingSilos = String.Empty;
tableEntry.SuspectingTimes = String.Empty;
tableEntry.SuspectingSilos = string.Empty;
tableEntry.SuspectingTimes = string.Empty;
}
tableEntry.PartitionKey = deploymentId;
tableEntry.RowKey = SiloInstanceTableEntry.ConstructRowKey(memEntry.SiloAddress);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public async Task<string> DumpSiloInstanceTable()
SiloInstanceTableEntry[] entries = queryResults.Select(entry => entry.Item1).ToArray();

var sb = new StringBuilder();
sb.Append(String.Format("Deployment {0}. Silos: ", DeploymentId));
sb.Append(string.Format("Deployment {0}. Silos: ", DeploymentId));

// Loop through the results, displaying information about the entity
Array.Sort(entries,
Expand All @@ -148,11 +148,11 @@ public async Task<string> DumpSiloInstanceTable()
if (e2 == null) return (e1 == null) ? 0 : 1;
if (e1.SiloName == null) return (e2.SiloName == null) ? 0 : -1;
if (e2.SiloName == null) return (e1.SiloName == null) ? 0 : 1;
return String.CompareOrdinal(e1.SiloName, e2.SiloName);
return string.CompareOrdinal(e1.SiloName, e2.SiloName);
});
foreach (SiloInstanceTableEntry entry in entries)
{
sb.AppendLine(String.Format("[IP {0}:{1}:{2}, {3}, Instance={4}, Status={5}]", entry.Address, entry.Port, entry.Generation,
sb.AppendLine(string.Format("[IP {0}:{1}:{2}, {3}, Instance={4}, Status={5}]", entry.Address, entry.Port, entry.Generation,
entry.HostName, entry.SiloName, entry.Status));
}
return sb.ToString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ private void CheckAlertSlowAccess(DateTime startOperation, string operation)

private void ReportErrorAndRethrow(Exception exc, string operation, AzureQueueErrorCode errorCode)
{
var errMsg = String.Format(
var errMsg = string.Format(
"Error doing {0} for Azure storage queue {1} " + Environment.NewLine
+ "Exception = {2}", operation, QueueName, exc);
logger.LogError((int)errorCode, exc, "{Message}", errMsg);
Expand Down Expand Up @@ -410,37 +410,37 @@ private void ValidateQueueName(string queueName)
if (!(queueName.Length >= 3 && queueName.Length <= 63))
{
// A queue name must be from 3 through 63 characters long.
throw new ArgumentException(String.Format("A queue name must be from 3 through 63 characters long, while your queueName length is {0}, queueName is {1}.", queueName.Length, queueName), queueName);
throw new ArgumentException(string.Format("A queue name must be from 3 through 63 characters long, while your queueName length is {0}, queueName is {1}.", queueName.Length, queueName), queueName);
}

if (!Char.IsLetterOrDigit(queueName.First()))
if (!char.IsLetterOrDigit(queueName.First()))
{
// A queue name must start with a letter or number
throw new ArgumentException(String.Format("A queue name must start with a letter or number, while your queueName is {0}.", queueName), queueName);
throw new ArgumentException(string.Format("A queue name must start with a letter or number, while your queueName is {0}.", queueName), queueName);
}

if (!Char.IsLetterOrDigit(queueName.Last()))
if (!char.IsLetterOrDigit(queueName.Last()))
{
// The first and last letters in the queue name must be alphanumeric. The dash (-) character cannot be the first or last character.
throw new ArgumentException(String.Format("The last letter in the queue name must be alphanumeric, while your queueName is {0}.", queueName), queueName);
throw new ArgumentException(string.Format("The last letter in the queue name must be alphanumeric, while your queueName is {0}.", queueName), queueName);
}

if (!queueName.All(c => Char.IsLetterOrDigit(c) || c.Equals('-')))
if (!queueName.All(c => char.IsLetterOrDigit(c) || c.Equals('-')))
{
// A queue name can only contain letters, numbers, and the dash (-) character.
throw new ArgumentException(String.Format("A queue name can only contain letters, numbers, and the dash (-) character, while your queueName is {0}.", queueName), queueName);
throw new ArgumentException(string.Format("A queue name can only contain letters, numbers, and the dash (-) character, while your queueName is {0}.", queueName), queueName);
}

if (queueName.Contains("--"))
{
// Consecutive dash characters are not permitted in the queue name.
throw new ArgumentException(String.Format("Consecutive dash characters are not permitted in the queue name, while your queueName is {0}.", queueName), queueName);
throw new ArgumentException(string.Format("Consecutive dash characters are not permitted in the queue name, while your queueName is {0}.", queueName), queueName);
}

if (queueName.Where(Char.IsLetter).Any(c => !Char.IsLower(c)))
if (queueName.Where(char.IsLetter).Any(c => !char.IsLower(c)))
{
// All letters in a queue name must be lowercase.
throw new ArgumentException(String.Format("All letters in a queue name must be lowercase, while your queueName is {0}.", queueName), queueName);
throw new ArgumentException(string.Format("All letters in a queue name must be lowercase, while your queueName is {0}.", queueName), queueName);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Azure/Shared/Storage/AzureTableUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public static bool IsRetriableHttpError(HttpStatusCode httpStatusCode, string re
|| httpStatusCode == HttpStatusCode.ServiceUnavailable /* 503 */
|| httpStatusCode == HttpStatusCode.GatewayTimeout /* 504 */
|| (httpStatusCode == HttpStatusCode.InternalServerError /* 500 */
&& !String.IsNullOrEmpty(restStatusCode)
&& !string.IsNullOrEmpty(restStatusCode)
&& TableErrorCode.OperationTimedOut.ToString().Equals(restStatusCode, StringComparison.OrdinalIgnoreCase))
);
}
Expand Down Expand Up @@ -247,7 +247,7 @@ internal static bool AnalyzeReadException(Exception exc, int iteration, string t
exc,
"DataNotFound reading Azure storage table {TableName}:{Retry} HTTP status code={StatusCode} REST status code={RESTStatusCode}",
tableName,
iteration == 0 ? String.Empty : (" Repeat=" + iteration),
iteration == 0 ? string.Empty : (" Repeat=" + iteration),
httpStatusCode,
restStatus);

Expand Down
2 changes: 1 addition & 1 deletion src/Orleans.Core.Abstractions/IDs/Legacy/LegacyGrainId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ private string ToStringImpl(bool detailed)
fullString = "???/" + idString;
break;
}
return detailed ? String.Format("{0}-0x{1, 8:X8}", fullString, GetUniformHashCode()) : fullString;
return detailed ? string.Format("{0}-0x{1, 8:X8}", fullString, GetUniformHashCode()) : fullString;
}

public static bool IsLegacyGrainType(Type type)
Expand Down
8 changes: 4 additions & 4 deletions src/Orleans.Core.Abstractions/IDs/Legacy/UniqueKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ public enum Category : byte
}

[Id(0)]
public UInt64 N0 { get; private set; }
public ulong N0 { get; private set; }
[Id(1)]
public UInt64 N1 { get; private set; }
public ulong N1 { get; private set; }
[Id(2)]
public UInt64 TypeCodeData { get; private set; }
public ulong TypeCodeData { get; private set; }
[Id(3)]
public string KeyExt { get; private set; }

Expand Down Expand Up @@ -332,7 +332,7 @@ internal string ToGrainKeyString()
return keyString;
}

internal static Category GetCategory(UInt64 typeCodeData)
internal static Category GetCategory(ulong typeCodeData)
{
return (Category)((typeCodeData >> 56) & 0xFF);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Orleans.Core/Configuration/ConfigUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public static string RedactConnectionStringInfo(string connectionString)
"SecretKey=", "SessionToken=", // DynamoDb
};
var mark = "<--SNIP-->";
if (String.IsNullOrEmpty(connectionString)) return "null";
if (string.IsNullOrEmpty(connectionString)) return "null";
//if connection string format doesn't contain any secretKey, then return just <--SNIP-->
if (!secretKeys.Any(key => connectionString.Contains(key))) return mark;

Expand Down
2 changes: 1 addition & 1 deletion src/Orleans.Core/Providers/IGrainStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public InconsistentStateException(string storedEtag, string currentEtag, Excepti
/// <inheritdoc/>
public override string ToString()
{
return String.Format("InconsistentStateException: {0} Expected Etag={1} Received Etag={2} {3}",
return string.Format("InconsistentStateException: {0} Expected Etag={1} Received Etag={2} {3}",
Message, StoredEtag, CurrentEtag, InnerException);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Orleans.Core/Timers/SafeTimerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ internal SafeTimerBase(ILogger logger, TimerCallback syncCallback, object state,

public void Start(TimeSpan due, TimeSpan period)
{
if (timerStarted) throw new InvalidOperationException(String.Format("Calling start on timer {0} is not allowed, since it was already created in a started mode with specified due.", GetFullName()));
if (timerStarted) throw new InvalidOperationException(string.Format("Calling start on timer {0} is not allowed, since it was already created in a started mode with specified due.", GetFullName()));
if (period == TimeSpan.Zero) throw new ArgumentOutOfRangeException(nameof(period), period, "Cannot use TimeSpan.Zero for timer period");

long dueTm = (long)dueTime.TotalMilliseconds;
Expand Down Expand Up @@ -146,7 +146,7 @@ private string GetFullName()
public bool CheckTimerFreeze(DateTime lastCheckTime, Func<string> callerName)
{
return CheckTimerDelay(previousTickTime, totalNumTicks,
dueTime, timerFrequency, logger, () => String.Format("{0}.{1}", GetFullName(), callerName()), ErrorCode.Timer_SafeTimerIsNotTicking, true);
dueTime, timerFrequency, logger, () => string.Format("{0}.{1}", GetFullName(), callerName()), ErrorCode.Timer_SafeTimerIsNotTicking, true);
}

public static bool CheckTimerDelay(DateTime previousTickTime, int totalNumTicks,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class LogConsistencyStatistics
/// <summary>
/// A map from event names to event counts
/// </summary>
public Dictionary<String, long> EventCounters;
public Dictionary<string, long> EventCounters;
/// <summary>
/// A list of all measured stabilization latencies
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ public ReminderTableData()
public IList<ReminderEntry> Reminders { get; private set; }

/// <summary>
/// Returns a <see cref="System.String" /> that represents this instance.
/// Returns a <see cref="string" /> that represents this instance.
/// </summary>
/// <returns>A <see cref="System.String" /> that represents this instance.</returns>
/// <returns>A <see cref="string" /> that represents this instance.</returns>
public override string ToString() => $"[{Reminders.Count} reminders: {Utils.EnumerableToString(Reminders)}.";
}

Expand Down
2 changes: 1 addition & 1 deletion src/Orleans.Runtime/Catalog/ActivationCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ private DateTime MakeTicketFromTimeSpan(TimeSpan timeout)
{
if (timeout < quantum)
{
throw new ArgumentException(String.Format("timeout must be at least {0}, but it is {1}", quantum, timeout), nameof(timeout));
throw new ArgumentException(string.Format("timeout must be at least {0}, but it is {1}", quantum, timeout), nameof(timeout));
}

return MakeTicketFromDateTime(DateTime.UtcNow + timeout);
Expand Down
6 changes: 3 additions & 3 deletions src/Orleans.Runtime/Core/SystemStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ private enum InternalSystemStatus
private readonly InternalSystemStatus value;
private SystemStatus(InternalSystemStatus name) { this.value = name; }

/// <see cref="Object.ToString"/>
/// <see cref="object.ToString"/>
public override string ToString() { return this.value.ToString(); }
/// <see cref="Object.GetHashCode"/>
/// <see cref="object.GetHashCode"/>
public override int GetHashCode() { return this.value.GetHashCode(); }
/// <see cref="Object.Equals(Object)"/>
/// <see cref="object.Equals(object)"/>
public override bool Equals(object obj) { var ss = obj as SystemStatus; return ss != null && this.Equals(ss); }
/// <see cref="IEquatable{T}.Equals(T)"/>
public bool Equals(SystemStatus other) { return (other != null) && this.value.Equals(other.value); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private static IGrainService GrainServiceFactory(Type serviceType, IServiceProvi
var grainServiceInterfaceType = serviceType.GetInterfaces().FirstOrDefault(x => x.GetInterfaces().Contains(typeof(IGrainService)));
if (grainServiceInterfaceType is null)
{
throw new InvalidOperationException(String.Format($"Cannot find an interface on {serviceType.FullName} which implements IGrainService"));
throw new InvalidOperationException(string.Format($"Cannot find an interface on {serviceType.FullName} which implements IGrainService"));
}

var typeCode = GrainInterfaceUtils.GetGrainClassTypeCode(grainServiceInterfaceType);
Expand Down
2 changes: 1 addition & 1 deletion src/Orleans.Runtime/Silo/Silo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ private Task OnRuntimeInitializeStart(CancellationToken ct)
lock (lockable)
{
if (!this.SystemStatus.Equals(SystemStatus.Created))
throw new InvalidOperationException(String.Format("Calling Silo.Start() on a silo which is not in the Created state. This silo is in the {0} state.", this.SystemStatus));
throw new InvalidOperationException(string.Format("Calling Silo.Start() on a silo which is not in the Created state. This silo is in the {0} state.", this.SystemStatus));

this.SystemStatus = SystemStatus.Starting;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Orleans.Runtime/Timers/GrainTimer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ internal static IGrainTimer FromTaskCallback(
public void Start()
{
if (TimerAlreadyStopped)
throw new ObjectDisposedException(String.Format("The timer {0} was already disposed.", GetFullName()));
throw new ObjectDisposedException(string.Format("The timer {0} was already disposed.", GetFullName()));

timer.Start(dueTime, timerFrequency);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public override int GetHashCode()

public override string ToString()
{
return String.Format("StreamSubscriptionHandleImpl:Stream={0},HandleId={1}", IsValid ? streamImpl.InternalStreamId.ToString() : "null", HandleId);
return string.Format("StreamSubscriptionHandleImpl:Stream={0},HandleId={1}", IsValid ? streamImpl.InternalStreamId.ToString() : "null", HandleId);
}
}
}
2 changes: 1 addition & 1 deletion src/Orleans.Streaming/MemoryStreams/MemoryPooledCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private ArraySegment<byte> SerializeMessageIntoPooledSegment(MemoryMessageData q
// if this fails with clean block, then requested size is too big
if (!currentBuffer.TryGetSegment(size, out segment))
{
string errmsg = String.Format(CultureInfo.InvariantCulture,
string errmsg = string.Format(CultureInfo.InvariantCulture,
"Message size is too big. MessageSize: {0}", size);
throw new ArgumentOutOfRangeException(nameof(queueMessage), errmsg);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public PersistentStreamProvider(
DeepCopier deepCopier,
ILogger<PersistentStreamProvider> logger)
{
if (String.IsNullOrEmpty(name)) throw new ArgumentNullException(nameof(name));
if (string.IsNullOrEmpty(name)) throw new ArgumentNullException(nameof(name));
if (runtime == null) throw new ArgumentNullException(nameof(runtime));
this.pubsubOptions = pubsubOptions ?? throw new ArgumentNullException(nameof(pubsubOptions));
this.Name = name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public QueueCacheMissException(StreamSequenceToken requested, StreamSequenceToke
/// <param name="low">The earliest available sequence token.</param>
/// <param name="high">The latest available sequence token.</param>
public QueueCacheMissException(string requested, string low, string high)
: this(String.Format(CultureInfo.InvariantCulture, MESSAGE_FORMAT, requested, low, high))
: this(string.Format(CultureInfo.InvariantCulture, MESSAGE_FORMAT, requested, low, high))
{
Requested = requested;
Low = low;
Expand Down
2 changes: 1 addition & 1 deletion src/Orleans.Streaming/QueueBalancer/BestFitBalancer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public Dictionary<TBucket, List<TResource>> GetDistribution(IEnumerable<TBucket>
{
if (!idealDistribution.ContainsKey(bucket))
{
throw new ArgumentOutOfRangeException(nameof(activeBuckets), String.Format("Active buckets contain a bucket {0} not in the master list.", bucket));
throw new ArgumentOutOfRangeException(nameof(activeBuckets), string.Format("Active buckets contain a bucket {0} not in the master list.", bucket));
}
}

Expand Down
Loading

0 comments on commit 7bd86bf

Please sign in to comment.