Using 'nameof' operator instead of magic strings

This commit is contained in:
Hisham Abdullah Bin Ateya 2015-05-07 01:26:40 +03:00
parent cef0971d3e
commit 54fc775b24
4 changed files with 7 additions and 7 deletions

View File

@ -33,7 +33,7 @@ namespace Microsoft.AspNet.Razor.Parser
{
if (activeParser != codeParser && activeParser != markupParser)
{
throw new ArgumentException(RazorResources.ActiveParser_Must_Be_Code_Or_Markup_Parser, "activeParser");
throw new ArgumentException(RazorResources.ActiveParser_Must_Be_Code_Or_Markup_Parser, nameof(activeParser));
}
CaptureOwnerTask();

View File

@ -72,7 +72,7 @@ namespace Microsoft.AspNet.Razor
{
if (string.IsNullOrEmpty(sourceFileName))
{
throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "sourceFileName");
throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, nameof(sourceFileName));
}
Host = host;

View File

@ -51,7 +51,7 @@ namespace Microsoft.AspNet.Razor.Text
var line = FindLine(absoluteIndex);
if (line == null)
{
throw new ArgumentOutOfRangeException("absoluteIndex");
throw new ArgumentOutOfRangeException(nameof(absoluteIndex));
}
var idx = absoluteIndex - line.Start;
return new CharacterReference(line.Content[idx], new SourceLocation(absoluteIndex, line.Index, idx));

View File

@ -35,19 +35,19 @@ namespace Microsoft.AspNet.Razor.Text
{
if (oldPosition < 0)
{
throw new ArgumentOutOfRangeException("oldPosition", CommonResources.FormatArgument_Must_Be_GreaterThanOrEqualTo(0));
throw new ArgumentOutOfRangeException(nameof(oldPosition), CommonResources.FormatArgument_Must_Be_GreaterThanOrEqualTo(0));
}
if (newPosition < 0)
{
throw new ArgumentOutOfRangeException("newPosition", CommonResources.FormatArgument_Must_Be_GreaterThanOrEqualTo(0));
throw new ArgumentOutOfRangeException(nameof(newPosition), CommonResources.FormatArgument_Must_Be_GreaterThanOrEqualTo(0));
}
if (oldLength < 0)
{
throw new ArgumentOutOfRangeException("oldLength", CommonResources.FormatArgument_Must_Be_GreaterThanOrEqualTo(0));
throw new ArgumentOutOfRangeException(nameof(oldLength), CommonResources.FormatArgument_Must_Be_GreaterThanOrEqualTo(0));
}
if (newLength < 0)
{
throw new ArgumentOutOfRangeException("newLength", CommonResources.FormatArgument_Must_Be_GreaterThanOrEqualTo(0));
throw new ArgumentOutOfRangeException(nameof(newLength), CommonResources.FormatArgument_Must_Be_GreaterThanOrEqualTo(0));
}
OldPosition = oldPosition;