提交 09c724c9 编写于 作者: D David Kean

Merge pull request #7871 from alexanderkozlenko/pr_nm_cm

Use nameof expression for exceptions in Compilers projects
......@@ -1383,7 +1383,7 @@ private void CheckModelAndSyntaxNodeToSpeculate(CSharpSyntaxNode syntax)
{
throw new ArgumentException(
"Not a valid position for a call to LookupBaseMembers (must be in a type with a base type)",
"position");
nameof(position));
}
container = baseType;
}
......@@ -4605,7 +4605,7 @@ private static NamespaceOrTypeSymbol ToLanguageSpecific(INamespaceOrTypeSymbol c
var result = container as NamespaceOrTypeSymbol;
if ((object)result == null)
{
throw new ArgumentException(CSharpResources.NotACSharpSymbol, "container");
throw new ArgumentException(CSharpResources.NotACSharpSymbol, nameof(container));
}
return result;
}
......
......@@ -754,12 +754,12 @@ public MethodSymbol Construct(ImmutableArray<TypeSymbol> typeArguments)
if (typeArguments.Any(TypeSymbolIsNullFunction))
{
throw new ArgumentException(CSharpResources.TypeArgumentCannotBeNull, "typeArguments");
throw new ArgumentException(CSharpResources.TypeArgumentCannotBeNull, nameof(typeArguments));
}
if (typeArguments.Length != this.Arity)
{
throw new ArgumentException(CSharpResources.WrongNumberOfTypeArguments, "typeArguments");
throw new ArgumentException(CSharpResources.WrongNumberOfTypeArguments, nameof(typeArguments));
}
if (TypeParametersMatchTypeArguments(this.TypeParameters, typeArguments))
......
......@@ -95,7 +95,7 @@ internal static SyntaxToken Create(SyntaxKind kind)
{
if (!SyntaxFacts.IsAnyToken(kind))
{
throw new ArgumentException(string.Format(CSharpResources.ThisMethodCanOnlyBeUsedToCreateTokens, kind), "kind");
throw new ArgumentException(string.Format(CSharpResources.ThisMethodCanOnlyBeUsedToCreateTokens, kind), nameof(kind));
}
return CreateMissing(kind, null, null);
......@@ -110,7 +110,7 @@ internal static SyntaxToken Create(SyntaxKind kind, CSharpSyntaxNode leading, CS
{
if (!SyntaxFacts.IsAnyToken(kind))
{
throw new ArgumentException(string.Format(CSharpResources.ThisMethodCanOnlyBeUsedToCreateTokens, kind), "kind");
throw new ArgumentException(string.Format(CSharpResources.ThisMethodCanOnlyBeUsedToCreateTokens, kind), nameof(kind));
}
return CreateMissing(kind, leading, trailing);
......
......@@ -242,18 +242,18 @@ public static SyntaxToken Token(SyntaxTriviaList leading, SyntaxKind kind, strin
{
case SyntaxKind.IdentifierToken:
// Have a different representation.
throw new ArgumentException(CSharpResources.UseVerbatimIdentifier, "kind");
throw new ArgumentException(CSharpResources.UseVerbatimIdentifier, nameof(kind));
case SyntaxKind.CharacterLiteralToken:
// Value should not have type string.
throw new ArgumentException(CSharpResources.UseLiteralForTokens, "kind");
throw new ArgumentException(CSharpResources.UseLiteralForTokens, nameof(kind));
case SyntaxKind.NumericLiteralToken:
// Value should not have type string.
throw new ArgumentException(CSharpResources.UseLiteralForNumeric, "kind");
throw new ArgumentException(CSharpResources.UseLiteralForNumeric, nameof(kind));
}
if (!SyntaxFacts.IsAnyToken(kind))
{
throw new ArgumentException(string.Format(CSharpResources.ThisMethodCanOnlyBeUsedToCreateTokens, kind), "kind");
throw new ArgumentException(string.Format(CSharpResources.ThisMethodCanOnlyBeUsedToCreateTokens, kind), nameof(kind));
}
return new SyntaxToken(Syntax.InternalSyntax.SyntaxFactory.Token((InternalSyntax.CSharpSyntaxNode)leading.Node, kind, text, valueText, (InternalSyntax.CSharpSyntaxNode)trailing.Node));
......
......@@ -119,7 +119,7 @@ public DesktopStrongNameProvider(ImmutableArray<string> keyFileSearchPaths = def
{
if (!keyFileSearchPaths.IsDefault && keyFileSearchPaths.Any(path => !PathUtilities.IsAbsolute(path)))
{
throw new ArgumentException(CodeAnalysisResources.AbsolutePathExpected, "keyFileSearchPaths");
throw new ArgumentException(CodeAnalysisResources.AbsolutePathExpected, nameof(keyFileSearchPaths));
}
_keyFileSearchPaths = keyFileSearchPaths.NullToEmpty();
......
......@@ -439,15 +439,15 @@ internal static IAssemblyName ToAssemblyNameObject(AssemblyName name)
{
#if SCRIPTING
throw new ArgumentException(Scripting.ScriptingResources.InvalidCharactersInAssemblyName, "name");
throw new ArgumentException(Scripting.ScriptingResources.InvalidCharactersInAssemblyName, nameof(name));
#elif WORKSPACE_DESKTOP
throw new ArgumentException(Microsoft.CodeAnalysis.WorkspaceDesktopResources.InvalidCharactersInAssemblyName, "name");
throw new ArgumentException(Microsoft.CodeAnalysis.WorkspaceDesktopResources.InvalidCharactersInAssemblyName, nameof(name));
#else
throw new ArgumentException(Microsoft.CodeAnalysis.CodeAnalysisResources.InvalidCharactersInAssemblyName, "name");
throw new ArgumentException(Microsoft.CodeAnalysis.CodeAnalysisResources.InvalidCharactersInAssemblyName, nameof(name));
#endif
}
......@@ -469,15 +469,15 @@ internal static IAssemblyName ToAssemblyNameObject(AssemblyName name)
{
#if SCRIPTING
throw new ArgumentException(Microsoft.CodeAnalysis.Scripting.ScriptingResources.InvalidCharactersInAssemblyName, "name");
throw new ArgumentException(Microsoft.CodeAnalysis.Scripting.ScriptingResources.InvalidCharactersInAssemblyName, nameof(name));
#elif WORKSPACE_DESKTOP
throw new ArgumentException(Microsoft.CodeAnalysis.WorkspaceDesktopResources.InvalidCharactersInAssemblyName, "name");
throw new ArgumentException(Microsoft.CodeAnalysis.WorkspaceDesktopResources.InvalidCharactersInAssemblyName, nameof(name));
#else
throw new ArgumentException(Microsoft.CodeAnalysis.CodeAnalysisResources.InvalidCharactersInAssemblyName, "name");
throw new ArgumentException(Microsoft.CodeAnalysis.CodeAnalysisResources.InvalidCharactersInAssemblyName, nameof(name));
#endif
}
......
......@@ -90,7 +90,7 @@ public static void IlasmTempAssembly(string declarations, bool appendDefaultHead
"The provided IL cannot be compiled." + Environment.NewLine +
program + " " + arguments + Environment.NewLine +
result,
"declarations");
nameof(declarations));
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册