Replaced magic strings with call to nameof
MODIFY
WalletWasabi/Models/ConcurrentHashSet.cs
WalletWasabi/Models/ConcurrentHashSet.cs
@@ -16,7 +16,7 @@ namespace WalletWasabi.Models
/// concurrently from multiple threads.
/// https://github.com/i3arnon/ConcurrentHashSet/
/// </remarks>
- [DebuggerDisplay("Count = {Count}")]
+ [DebuggerDisplay("Count = {" + nameof(Count) + "}")]
public class ConcurrentHashSet<T> : IReadOnlyCollection<T>, ICollection<T>
{
private const int DefaultCapacity = 31;

MODIFY
WalletWasabi/Mono/Option.cs
WalletWasabi/Mono/Option.cs
@@ -178,17 +178,17 @@ namespace Mono.Options
{
if (prototype is null)
{
- throw new ArgumentNullException("prototype");
+ throw new ArgumentNullException(nameof(prototype));
}
if (prototype.Length == 0)
{
- throw new ArgumentException("Cannot be the empty string.", "prototype");
+ throw new ArgumentException("Cannot be the empty string.", nameof(prototype));
}
if (maxValueCount < 0)
{
- throw new ArgumentOutOfRangeException("maxValueCount");
+ throw new ArgumentOutOfRangeException(nameof(maxValueCount));
}
Prototype = prototype;
@@ -213,14 +213,14 @@ namespace Mono.Options
throw new ArgumentException(
"Cannot provide maxValueCount of 0 for OptionValueType.Required or " +
"OptionValueType.Optional.",
- "maxValueCount");
+ nameof(maxValueCount));
}
if (OptionValueType == OptionValueType.None && maxValueCount > 1)
{
throw new ArgumentException(
string.Format("Cannot provide maxValueCount of {0} for OptionValueType.None.", maxValueCount),
- "maxValueCount");
+ nameof(maxValueCount));
}
if (Array.IndexOf(Names, "<>") >= 0 &&
@@ -229,7 +229,7 @@ namespace Mono.Options
{
throw new ArgumentException(
"The default option handler '<>' cannot require values.",
- "prototype");
+ nameof(prototype));
}
}

MODIFY
WalletWasabi/Mono/OptionSet.cs
WalletWasabi/Mono/OptionSet.cs
@@ -213,7 +213,7 @@ namespace Mono.Options
{
if (option is null)
{
- throw new ArgumentNullException("option");
+ throw new ArgumentNullException(nameof(option));
}
try
@@ -253,7 +253,7 @@ namespace Mono.Options
{
if (option is null)
{
- throw new ArgumentNullException("option");
+ throw new ArgumentNullException(nameof(option));
}
List<string> added = new List<string>(option.Names.Length);
@@ -281,7 +281,7 @@ namespace Mono.Options
{
if (header is null)
{
- throw new ArgumentNullException("header");
+ throw new ArgumentNullException(nameof(header));
}
Add(new Category(header));
@@ -320,7 +320,7 @@ namespace Mono.Options
public ActionOption(string prototype, string description, int count, Action<OptionValueCollection> action, bool hidden)
: base(prototype, description, count, hidden)
{
- Action = action ?? throw new ArgumentNullException("action");
+ Action = action ?? throw new ArgumentNullException(nameof(action));
}
public Action<OptionValueCollection> Action { get; set; }
@@ -345,7 +345,7 @@ namespace Mono.Options
{
if (action is null)
{
- throw new ArgumentNullException("action");
+ throw new ArgumentNullException(nameof(action));
}
Option p = new ActionOption(prototype, description, 1,
@@ -368,7 +368,7 @@ namespace Mono.Options
{
if (action is null)
{
- throw new ArgumentNullException("action");
+ throw new ArgumentNullException(nameof(action));
}
Option p = new ActionOption(prototype, description, 2,
@@ -382,7 +382,7 @@ namespace Mono.Options
public ActionOption(string prototype, string description, Action<T> action)
: base(prototype, description, 1)
{
- Action = action ?? throw new ArgumentNullException("action");
+ Action = action ?? throw new ArgumentNullException(nameof(action));
}
public Action<T> Action { get; set; }
@@ -398,7 +398,7 @@ namespace Mono.Options
public ActionOption(string prototype, string description, OptionAction<TKey, TValue> action)
: base(prototype, description, 2)
{
- Action = action ?? throw new ArgumentNullException("action");
+ Action = action ?? throw new ArgumentNullException(nameof(action));
}
public OptionAction<TKey, TValue> Action { get; set; }
@@ -435,7 +435,7 @@ namespace Mono.Options
{
if (source is null)
{
- throw new ArgumentNullException("source");
+ throw new ArgumentNullException(nameof(source));
}
Sources.Add(source);
@@ -451,7 +451,7 @@ namespace Mono.Options
{
if (arguments is null)
{
- throw new ArgumentNullException("arguments");
+ throw new ArgumentNullException(nameof(arguments));
}
OptionContext c = CreateOptionContext();
@@ -563,7 +563,7 @@ namespace Mono.Options
{
if (argument is null)
{
- throw new ArgumentNullException("argument");
+ throw new ArgumentNullException(nameof(argument));
}
flag = name = sep = value = null;

MODIFY
WalletWasabi/Mono/OptionValueCollection.cs
WalletWasabi/Mono/OptionValueCollection.cs
@@ -298,7 +298,7 @@ namespace Mono.Options
if (index >= C.Option.MaxValueCount)
{
- throw new ArgumentOutOfRangeException("index");
+ throw new ArgumentOutOfRangeException(nameof(index));
}
if (C.Option.OptionValueType == OptionValueType.Required &&

MODIFY
WalletWasabi/Mono/StringCoda.cs
WalletWasabi/Mono/StringCoda.cs
@@ -173,7 +173,7 @@ namespace Mono.Options
{
if (widths is null)
{
- throw new ArgumentNullException("widths");
+ throw new ArgumentNullException(nameof(widths));
}
return CreateWrappedLinesIterator(self, widths);

MODIFY
WalletWasabi/Nito/AsyncEx/DefaultAsyncWaitQueue.cs
WalletWasabi/Nito/AsyncEx/DefaultAsyncWaitQueue.cs
@@ -13,7 +13,7 @@ namespace Nito.AsyncEx
/// The default wait queue implementation, which uses a double-ended queue.
/// </summary>
/// <typeparam name="T">The type of the results. If this isn't needed, use <see cref="object"/>.</typeparam>
- [DebuggerDisplay("Count = {Count}")]
+ [DebuggerDisplay("Count = {" + nameof(Count) + "}")]
[DebuggerTypeProxy(typeof(DefaultAsyncWaitQueue<>.DebugView))]
public sealed class DefaultAsyncWaitQueue<T> : IAsyncWaitQueue<T>
{

MODIFY
WalletWasabi/Nito/Collections/Deque.cs
WalletWasabi/Nito/Collections/Deque.cs
@@ -340,12 +340,12 @@ namespace Nito.Collections
{
if (value is null && default(T) != null)
{
- throw new ArgumentNullException("value", "Value cannot be null.");
+ throw new ArgumentNullException(nameof(value), "Value cannot be null.");
}
if (!IsT(value))
{
- throw new ArgumentException("Value is of incorrect type.", "value");
+ throw new ArgumentException("Value is of incorrect type.", nameof(value));
}
Insert(index, (T)value);

Replaced magic strings with call to nameof