React to Razor error length change.

aspnet/Razor#386
This commit is contained in:
N. Taylor Mullen 2015-09-02 15:37:58 -07:00
parent 4fb2053f34
commit 1d865afe7f
3 changed files with 16 additions and 10 deletions

View File

@ -42,8 +42,10 @@ namespace Microsoft.AspNet.Mvc.Razor
{
if (_modelStatementFound && _endInheritsLocation.HasValue)
{
Context.OnError(_endInheritsLocation.Value,
Resources.FormatMvcRazorCodeParser_CannotHaveModelAndInheritsKeyword(ModelKeyword));
Context.OnError(
_endInheritsLocation.Value,
Resources.FormatMvcRazorCodeParser_CannotHaveModelAndInheritsKeyword(ModelKeyword),
SyntaxConstants.CSharp.InheritsKeyword.Length);
}
}
@ -60,9 +62,10 @@ namespace Microsoft.AspNet.Mvc.Razor
if (_modelStatementFound)
{
Context.OnError(startModelLocation,
Resources.FormatMvcRazorCodeParser_OnlyOneModelStatementIsAllowed(ModelKeyword),
ModelKeyword.Length);
Context.OnError(
startModelLocation,
Resources.FormatMvcRazorCodeParser_OnlyOneModelStatementIsAllowed(ModelKeyword),
ModelKeyword.Length);
}
_modelStatementFound = true;

View File

@ -68,10 +68,13 @@ namespace Microsoft.AspNet.Mvc.Razor
_modelExpressionTypeName,
StringComparison.Ordinal))
{
errorSink.OnError(SourceLocation.Undefined, Resources.FormatMvcRazorParser_InvalidPropertyType(
descriptor.TypeName,
attributeDescriptor.Name,
_modelExpressionTypeName));
errorSink.OnError(
SourceLocation.Undefined,
Resources.FormatMvcRazorParser_InvalidPropertyType(
descriptor.TypeName,
attributeDescriptor.Name,
_modelExpressionTypeName),
length: 0);
}
}
}

View File

@ -139,7 +139,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
GetOptions(fileProvider));
var errors = new[]
{
new RazorError("message-1", new SourceLocation(1, 2, 17)),
new RazorError("message-1", new SourceLocation(1, 2, 17), length: 1),
new RazorError("message-2", new SourceLocation(viewPath, 1, 4, 6), 7),
new RazorError { Message = "message-3" },
new RazorError("message-4", new SourceLocation(viewImportsPath, 1, 3, 8), 4),