From 1d865afe7f48a72ed93f540d867db7adbcd8b945 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Wed, 2 Sep 2015 15:37:58 -0700 Subject: [PATCH] React to Razor error length change. aspnet/Razor#386 --- .../MvcRazorCodeParser.cs | 13 ++++++++----- .../MvcRazorParser.cs | 11 +++++++---- .../Compilation/RazorCompilationServiceTest.cs | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorCodeParser.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorCodeParser.cs index 5e84fe68da..8cc621e39f 100644 --- a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorCodeParser.cs +++ b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorCodeParser.cs @@ -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; diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorParser.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorParser.cs index 3ce13ef757..78f5e408ab 100644 --- a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorParser.cs +++ b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorParser.cs @@ -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); } } } diff --git a/test/Microsoft.AspNet.Mvc.Razor.Test/Compilation/RazorCompilationServiceTest.cs b/test/Microsoft.AspNet.Mvc.Razor.Test/Compilation/RazorCompilationServiceTest.cs index 6e96d4a1f1..b18298cc1b 100644 --- a/test/Microsoft.AspNet.Mvc.Razor.Test/Compilation/RazorCompilationServiceTest.cs +++ b/test/Microsoft.AspNet.Mvc.Razor.Test/Compilation/RazorCompilationServiceTest.cs @@ -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),