提交 64fd3776 编写于 作者: B bartkoelman

Use nameof() in calls to ArgumentException ctor

上级 f21b13d4
......@@ -23,7 +23,7 @@ public LinePositionSpan(LinePosition start, LinePosition end)
{
if (end < start)
{
throw new ArgumentException("end", CodeAnalysisResources.EndMustNotBeLessThanStart);
throw new ArgumentException(CodeAnalysisResources.EndMustNotBeLessThanStart, nameof(end));
}
_start = start;
......
......@@ -41,7 +41,7 @@ public static SyntaxNodeOrToken FindNodeOrTokenByKind(this SyntaxTree syntaxTree
{
if (!(occurrence > 0))
{
throw new ArgumentException("Specified value must be greater than zero.", "occurrence");
throw new ArgumentException("Specified value must be greater than zero.", nameof(occurrence));
}
SyntaxNodeOrToken foundNode = default(SyntaxNodeOrToken);
if (TryFindNodeOrToken(syntaxTree.GetCompilationUnitRoot(), kind, ref occurrence, ref foundNode))
......
......@@ -16,7 +16,7 @@ public DirectoryHelper(string path)
{
if (!Directory.Exists(path))
{
throw new ArgumentException("Directory '" + path + "' does not exist.", "path");
throw new ArgumentException("Directory '" + path + "' does not exist.", nameof(path));
}
_rootPath = path;
......
......@@ -35,7 +35,7 @@ public abstract class DkmDataContainer
{
if (_dataItems.ContainsKey(key))
{
throw new ArgumentException("Data item already exists", "item");
throw new ArgumentException("Data item already exists", nameof(item));
}
}
......
......@@ -148,7 +148,7 @@ public AssemblyLoadResult LoadFromPath(string path)
if (!PathUtilities.IsAbsolute(path))
{
throw new ArgumentException("Path must be absolute", "path");
throw new ArgumentException("Path must be absolute", nameof(path));
}
try
......
......@@ -303,7 +303,7 @@ internal static void ValidateNamespace(string @namespace)
if (!@namespace.IsValidClrNamespaceName())
{
throw new ArgumentException("Invalid namespace name", "namespace");
throw new ArgumentException("Invalid namespace name", nameof(@namespace));
}
}
......
......@@ -64,7 +64,7 @@ private static void Verify(IEnumerable<Diagnostic> actual, DiagnosticDescription
{
if (expected == null)
{
throw new ArgumentException("Must specify expected errors.", "expected");
throw new ArgumentException("Must specify expected errors.", nameof(expected));
}
var unmatched = actual.Select(d => new DiagnosticDescription(d, errorCodeOnly)).ToList();
......
......@@ -14,7 +14,7 @@ public static IEnumerable<Type> GetAllTypesImplementingGivenInterface(Assembly a
{
if (assembly == null || interfaceType == null || !interfaceType.IsInterface)
{
throw new ArgumentException("interfaceType is not an interface.", "interfaceType");
throw new ArgumentException("interfaceType is not an interface.", nameof(interfaceType));
}
return assembly.GetTypes().Where((t) =>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册