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

View File

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

View File

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