From 9b267dadbdb05b6cb4a29c3a9bac694ac06da4fb Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Thu, 8 May 2014 14:55:10 -0700 Subject: [PATCH] Modify line pragma formatting supporters. Modified the dummy line pragmas arround expression chunk blocks to be accurate to avoid bad error messages. #30 --- .../CodeBuilder/CSharp/Visitors/CSharpCodeVisitor.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/CSharp/Visitors/CSharpCodeVisitor.cs b/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/CSharp/Visitors/CSharpCodeVisitor.cs index 8625d467bb..7ab0992a7f 100644 --- a/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/CSharp/Visitors/CSharpCodeVisitor.cs +++ b/src/Microsoft.AspNet.Razor/Generator/Compiler/CodeBuilder/CSharp/Visitors/CSharpCodeVisitor.cs @@ -303,15 +303,16 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp string designTimeAssignment = "__o = "; Writer.ResetIndent(); + var documentLocation = firstChild.Association.Start; // This is only here to enable accurate formatting by the C# editor. - Writer.WriteLineNumberDirective(1, "------------------------------------------"); + Writer.WriteLineNumberDirective(documentLocation.LineIndex + 1, Context.SourceFile); // We build the padding with an offset of the design time assignment statement. Writer.Write(_paddingBuilder.BuildExpressionPadding((Span)firstChild.Association, designTimeAssignment.Length)) .Write(designTimeAssignment); // We map the first line of code but do not write the line pragmas associated with it. - CreateRawCodeMapping(firstChild.Code, firstChild.Association.Start); + CreateRawCodeMapping(firstChild.Code, documentLocation); // Render all but the first child. // The reason why we render the other children differently is because when formatting the C# code