Make SourceSpan public

Cleansup SourceSpan and makes it public where its used.
This commit is contained in:
Ryan Nowak 2017-01-03 12:46:56 -08:00
parent eb0a2a1833
commit e104451f79
44 changed files with 217 additions and 307 deletions

105
Razor.sln
View File

@ -1,30 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15 # Visual Studio 15
VisualStudioVersion = 15.0.26009.0 VisualStudioVersion = 15.0.26014.0
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{3C0D6505-79B3-49D0-B4C3-176F0F1836ED}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{3C0D6505-79B3-49D0-B4C3-176F0F1836ED}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{92463391-81BE-462B-AC3C-78C6C760741F}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{92463391-81BE-462B-AC3C-78C6C760741F}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor", "src\Microsoft.AspNetCore.Razor\Microsoft.AspNetCore.Razor.csproj", "{EDA30434-C567-44DC-B8B6-2566A7F77163}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Test", "test\Microsoft.AspNetCore.Razor.Test\Microsoft.AspNetCore.Razor.Test.csproj", "{87C7338B-0C06-4C7B-BE75-A2368AE26797}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Runtime", "src\Microsoft.AspNetCore.Razor.Runtime\Microsoft.AspNetCore.Razor.Runtime.csproj", "{D0196096-1B01-4133-AACE-1A10A0F7247C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F8C12DD6-659D-405A-AA27-FB22AD92A010}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F8C12DD6-659D-405A-AA27-FB22AD92A010}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
global.json = global.json global.json = global.json
NuGet.config = NuGet.config NuGet.config = NuGet.config
EndProjectSection EndProjectSection
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RazorPageGenerator", "src\RazorPageGenerator\RazorPageGenerator.csproj", "{7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Evolution", "src\Microsoft.AspNetCore.Razor.Evolution\Microsoft.AspNetCore.Razor.Evolution.csproj", "{932F3C9C-A6C0-40D3-BA50-9309886242FC}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Evolution", "src\Microsoft.AspNetCore.Razor.Evolution\Microsoft.AspNetCore.Razor.Evolution.csproj", "{932F3C9C-A6C0-40D3-BA50-9309886242FC}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Evolution.Test", "test\Microsoft.AspNetCore.Razor.Evolution.Test\Microsoft.AspNetCore.Razor.Evolution.Test.csproj", "{969357A4-CCF1-46D9-B002-9AA072AFC75C}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Evolution.Test", "test\Microsoft.AspNetCore.Razor.Evolution.Test\Microsoft.AspNetCore.Razor.Evolution.Test.csproj", "{9077988C-F1E0-4758-9D0C-FE3A937579E5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Runtime.Test", "test\Microsoft.AspNetCore.Razor.Runtime.Test\Microsoft.AspNetCore.Razor.Runtime.Test.csproj", "{277AB67E-9C8D-4799-A18C-C628E70A8664}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -36,54 +26,6 @@ Global
Release|x86 = Release|x86 Release|x86 = Release|x86
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EDA30434-C567-44DC-B8B6-2566A7F77163}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EDA30434-C567-44DC-B8B6-2566A7F77163}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EDA30434-C567-44DC-B8B6-2566A7F77163}.Debug|x64.ActiveCfg = Debug|x64
{EDA30434-C567-44DC-B8B6-2566A7F77163}.Debug|x64.Build.0 = Debug|x64
{EDA30434-C567-44DC-B8B6-2566A7F77163}.Debug|x86.ActiveCfg = Debug|x86
{EDA30434-C567-44DC-B8B6-2566A7F77163}.Debug|x86.Build.0 = Debug|x86
{EDA30434-C567-44DC-B8B6-2566A7F77163}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EDA30434-C567-44DC-B8B6-2566A7F77163}.Release|Any CPU.Build.0 = Release|Any CPU
{EDA30434-C567-44DC-B8B6-2566A7F77163}.Release|x64.ActiveCfg = Release|x64
{EDA30434-C567-44DC-B8B6-2566A7F77163}.Release|x64.Build.0 = Release|x64
{EDA30434-C567-44DC-B8B6-2566A7F77163}.Release|x86.ActiveCfg = Release|x86
{EDA30434-C567-44DC-B8B6-2566A7F77163}.Release|x86.Build.0 = Release|x86
{87C7338B-0C06-4C7B-BE75-A2368AE26797}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{87C7338B-0C06-4C7B-BE75-A2368AE26797}.Debug|Any CPU.Build.0 = Debug|Any CPU
{87C7338B-0C06-4C7B-BE75-A2368AE26797}.Debug|x64.ActiveCfg = Debug|x64
{87C7338B-0C06-4C7B-BE75-A2368AE26797}.Debug|x64.Build.0 = Debug|x64
{87C7338B-0C06-4C7B-BE75-A2368AE26797}.Debug|x86.ActiveCfg = Debug|x86
{87C7338B-0C06-4C7B-BE75-A2368AE26797}.Debug|x86.Build.0 = Debug|x86
{87C7338B-0C06-4C7B-BE75-A2368AE26797}.Release|Any CPU.ActiveCfg = Release|Any CPU
{87C7338B-0C06-4C7B-BE75-A2368AE26797}.Release|Any CPU.Build.0 = Release|Any CPU
{87C7338B-0C06-4C7B-BE75-A2368AE26797}.Release|x64.ActiveCfg = Release|x64
{87C7338B-0C06-4C7B-BE75-A2368AE26797}.Release|x64.Build.0 = Release|x64
{87C7338B-0C06-4C7B-BE75-A2368AE26797}.Release|x86.ActiveCfg = Release|x86
{87C7338B-0C06-4C7B-BE75-A2368AE26797}.Release|x86.Build.0 = Release|x86
{D0196096-1B01-4133-AACE-1A10A0F7247C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D0196096-1B01-4133-AACE-1A10A0F7247C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D0196096-1B01-4133-AACE-1A10A0F7247C}.Debug|x64.ActiveCfg = Debug|x64
{D0196096-1B01-4133-AACE-1A10A0F7247C}.Debug|x64.Build.0 = Debug|x64
{D0196096-1B01-4133-AACE-1A10A0F7247C}.Debug|x86.ActiveCfg = Debug|x86
{D0196096-1B01-4133-AACE-1A10A0F7247C}.Debug|x86.Build.0 = Debug|x86
{D0196096-1B01-4133-AACE-1A10A0F7247C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D0196096-1B01-4133-AACE-1A10A0F7247C}.Release|Any CPU.Build.0 = Release|Any CPU
{D0196096-1B01-4133-AACE-1A10A0F7247C}.Release|x64.ActiveCfg = Release|x64
{D0196096-1B01-4133-AACE-1A10A0F7247C}.Release|x64.Build.0 = Release|x64
{D0196096-1B01-4133-AACE-1A10A0F7247C}.Release|x86.ActiveCfg = Release|x86
{D0196096-1B01-4133-AACE-1A10A0F7247C}.Release|x86.Build.0 = Release|x86
{7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.Debug|x64.ActiveCfg = Debug|x64
{7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.Debug|x64.Build.0 = Debug|x64
{7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.Debug|x86.ActiveCfg = Debug|x86
{7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.Debug|x86.Build.0 = Debug|x86
{7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.Release|Any CPU.Build.0 = Release|Any CPU
{7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.Release|x64.ActiveCfg = Release|x64
{7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.Release|x64.Build.0 = Release|x64
{7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.Release|x86.ActiveCfg = Release|x86
{7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}.Release|x86.Build.0 = Release|x86
{932F3C9C-A6C0-40D3-BA50-9309886242FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {932F3C9C-A6C0-40D3-BA50-9309886242FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{932F3C9C-A6C0-40D3-BA50-9309886242FC}.Debug|Any CPU.Build.0 = Debug|Any CPU {932F3C9C-A6C0-40D3-BA50-9309886242FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{932F3C9C-A6C0-40D3-BA50-9309886242FC}.Debug|x64.ActiveCfg = Debug|x64 {932F3C9C-A6C0-40D3-BA50-9309886242FC}.Debug|x64.ActiveCfg = Debug|x64
@ -96,41 +38,24 @@ Global
{932F3C9C-A6C0-40D3-BA50-9309886242FC}.Release|x64.Build.0 = Release|x64 {932F3C9C-A6C0-40D3-BA50-9309886242FC}.Release|x64.Build.0 = Release|x64
{932F3C9C-A6C0-40D3-BA50-9309886242FC}.Release|x86.ActiveCfg = Release|x86 {932F3C9C-A6C0-40D3-BA50-9309886242FC}.Release|x86.ActiveCfg = Release|x86
{932F3C9C-A6C0-40D3-BA50-9309886242FC}.Release|x86.Build.0 = Release|x86 {932F3C9C-A6C0-40D3-BA50-9309886242FC}.Release|x86.Build.0 = Release|x86
{969357A4-CCF1-46D9-B002-9AA072AFC75C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9077988C-F1E0-4758-9D0C-FE3A937579E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{969357A4-CCF1-46D9-B002-9AA072AFC75C}.Debug|Any CPU.Build.0 = Debug|Any CPU {9077988C-F1E0-4758-9D0C-FE3A937579E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{969357A4-CCF1-46D9-B002-9AA072AFC75C}.Debug|x64.ActiveCfg = Debug|x64 {9077988C-F1E0-4758-9D0C-FE3A937579E5}.Debug|x64.ActiveCfg = Debug|x64
{969357A4-CCF1-46D9-B002-9AA072AFC75C}.Debug|x64.Build.0 = Debug|x64 {9077988C-F1E0-4758-9D0C-FE3A937579E5}.Debug|x64.Build.0 = Debug|x64
{969357A4-CCF1-46D9-B002-9AA072AFC75C}.Debug|x86.ActiveCfg = Debug|x86 {9077988C-F1E0-4758-9D0C-FE3A937579E5}.Debug|x86.ActiveCfg = Debug|x86
{969357A4-CCF1-46D9-B002-9AA072AFC75C}.Debug|x86.Build.0 = Debug|x86 {9077988C-F1E0-4758-9D0C-FE3A937579E5}.Debug|x86.Build.0 = Debug|x86
{969357A4-CCF1-46D9-B002-9AA072AFC75C}.Release|Any CPU.ActiveCfg = Release|Any CPU {9077988C-F1E0-4758-9D0C-FE3A937579E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{969357A4-CCF1-46D9-B002-9AA072AFC75C}.Release|Any CPU.Build.0 = Release|Any CPU {9077988C-F1E0-4758-9D0C-FE3A937579E5}.Release|Any CPU.Build.0 = Release|Any CPU
{969357A4-CCF1-46D9-B002-9AA072AFC75C}.Release|x64.ActiveCfg = Release|x64 {9077988C-F1E0-4758-9D0C-FE3A937579E5}.Release|x64.ActiveCfg = Release|x64
{969357A4-CCF1-46D9-B002-9AA072AFC75C}.Release|x64.Build.0 = Release|x64 {9077988C-F1E0-4758-9D0C-FE3A937579E5}.Release|x64.Build.0 = Release|x64
{969357A4-CCF1-46D9-B002-9AA072AFC75C}.Release|x86.ActiveCfg = Release|x86 {9077988C-F1E0-4758-9D0C-FE3A937579E5}.Release|x86.ActiveCfg = Release|x86
{969357A4-CCF1-46D9-B002-9AA072AFC75C}.Release|x86.Build.0 = Release|x86 {9077988C-F1E0-4758-9D0C-FE3A937579E5}.Release|x86.Build.0 = Release|x86
{277AB67E-9C8D-4799-A18C-C628E70A8664}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{277AB67E-9C8D-4799-A18C-C628E70A8664}.Debug|Any CPU.Build.0 = Debug|Any CPU
{277AB67E-9C8D-4799-A18C-C628E70A8664}.Debug|x64.ActiveCfg = Debug|x64
{277AB67E-9C8D-4799-A18C-C628E70A8664}.Debug|x64.Build.0 = Debug|x64
{277AB67E-9C8D-4799-A18C-C628E70A8664}.Debug|x86.ActiveCfg = Debug|x86
{277AB67E-9C8D-4799-A18C-C628E70A8664}.Debug|x86.Build.0 = Debug|x86
{277AB67E-9C8D-4799-A18C-C628E70A8664}.Release|Any CPU.ActiveCfg = Release|Any CPU
{277AB67E-9C8D-4799-A18C-C628E70A8664}.Release|Any CPU.Build.0 = Release|Any CPU
{277AB67E-9C8D-4799-A18C-C628E70A8664}.Release|x64.ActiveCfg = Release|x64
{277AB67E-9C8D-4799-A18C-C628E70A8664}.Release|x64.Build.0 = Release|x64
{277AB67E-9C8D-4799-A18C-C628E70A8664}.Release|x86.ActiveCfg = Release|x86
{277AB67E-9C8D-4799-A18C-C628E70A8664}.Release|x86.Build.0 = Release|x86
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(NestedProjects) = preSolution GlobalSection(NestedProjects) = preSolution
{EDA30434-C567-44DC-B8B6-2566A7F77163} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
{87C7338B-0C06-4C7B-BE75-A2368AE26797} = {92463391-81BE-462B-AC3C-78C6C760741F}
{D0196096-1B01-4133-AACE-1A10A0F7247C} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
{7BE58880-36AD-4CD5-9E16-2A5AFEA790EF} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
{932F3C9C-A6C0-40D3-BA50-9309886242FC} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED} {932F3C9C-A6C0-40D3-BA50-9309886242FC} = {3C0D6505-79B3-49D0-B4C3-176F0F1836ED}
{969357A4-CCF1-46D9-B002-9AA072AFC75C} = {92463391-81BE-462B-AC3C-78C6C760741F} {9077988C-F1E0-4758-9D0C-FE3A937579E5} = {92463391-81BE-462B-AC3C-78C6C760741F}
{277AB67E-9C8D-4799-A18C-C628E70A8664} = {92463391-81BE-462B-AC3C-78C6C760741F}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@ -54,11 +54,11 @@ namespace Microsoft.AspNetCore.Razor.Evolution
return; return;
} }
if (node.SourceRange != null) if (node.Source != null)
{ {
using (new LinePragmaWriter(Context.Writer, node.SourceRange)) using (new LinePragmaWriter(Context.Writer, node.Source.Value))
{ {
var padding = BuildOffsetPadding(RazorDesignTimeIRPass.DesignTimeVariable.Length, node.SourceRange, Context); var padding = BuildOffsetPadding(RazorDesignTimeIRPass.DesignTimeVariable.Length, node.Source.Value, Context);
Context.Writer Context.Writer
.Write(padding) .Write(padding)
@ -94,11 +94,11 @@ namespace Microsoft.AspNetCore.Razor.Evolution
public override void VisitCSharpStatement(CSharpStatementIRNode node) public override void VisitCSharpStatement(CSharpStatementIRNode node)
{ {
if (node.SourceRange != null) if (node.Source != null)
{ {
using (new LinePragmaWriter(Context.Writer, node.SourceRange)) using (new LinePragmaWriter(Context.Writer, node.Source.Value))
{ {
var padding = BuildOffsetPadding(0, node.SourceRange, Context); var padding = BuildOffsetPadding(0, node.Source.Value, Context);
Context.Writer.Write(padding); Context.Writer.Write(padding);
AddLineMappingFor(node); AddLineMappingFor(node);
@ -116,7 +116,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution
const string TypeHelper = "__typeHelper"; const string TypeHelper = "__typeHelper";
var tokenKind = node.Descriptor.Kind; var tokenKind = node.Descriptor.Kind;
if (node.SourceRange == null || node.Descriptor.Kind == DirectiveTokenKind.Literal) if (node.Source == null || node.Descriptor.Kind == DirectiveTokenKind.Literal)
{ {
return; return;
} }
@ -268,10 +268,10 @@ namespace Microsoft.AspNetCore.Razor.Evolution
} }
else else
{ {
var firstMappedChild = node.Children.FirstOrDefault(child => child.SourceRange != null) as RazorIRNode; var firstMappedChild = node.Children.FirstOrDefault(child => child.Source != null) as RazorIRNode;
var valueStart = firstMappedChild?.SourceRange; var valueStart = firstMappedChild?.Source;
using (new LinePragmaWriter(Context.Writer, node.SourceRange)) using (new LinePragmaWriter(Context.Writer, node.Source.Value))
{ {
var assignmentPrefixLength = propertyValueAccessor.Length + " = ".Length; var assignmentPrefixLength = propertyValueAccessor.Length + " = ".Length;
if (node.Descriptor.IsEnum && if (node.Descriptor.IsEnum &&
@ -282,7 +282,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution
if (valueStart != null) if (valueStart != null)
{ {
var padding = BuildOffsetPadding(assignmentPrefixLength, node.SourceRange, Context); var padding = BuildOffsetPadding(assignmentPrefixLength, node.Source.Value, Context);
Context.Writer.Write(padding); Context.Writer.Write(padding);
} }
@ -297,7 +297,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution
{ {
if (valueStart != null) if (valueStart != null)
{ {
var padding = BuildOffsetPadding(assignmentPrefixLength, node.SourceRange, Context); var padding = BuildOffsetPadding(assignmentPrefixLength, node.Source.Value, Context);
Context.Writer.Write(padding); Context.Writer.Write(padding);
} }
@ -305,7 +305,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution
Context.Writer.WriteStartAssignment(propertyValueAccessor); Context.Writer.WriteStartAssignment(propertyValueAccessor);
} }
RenderTagHelperAttributeInline(node, node.SourceRange); RenderTagHelperAttributeInline(node, node.Source.Value);
Context.Writer.WriteLine(";"); Context.Writer.WriteLine(";");
} }
@ -328,8 +328,8 @@ namespace Microsoft.AspNetCore.Razor.Evolution
private void AddLineMappingFor(RazorIRNode node) private void AddLineMappingFor(RazorIRNode node)
{ {
var sourceLocation = node.SourceRange; var sourceLocation = node.Source.Value;
var generatedLocation = new MappingLocation(Context.Writer.GetCurrentSourceLocation(), node.SourceRange.ContentLength); var generatedLocation = new SourceSpan(Context.Writer.GetCurrentSourceLocation(), sourceLocation.Length);
var lineMapping = new LineMapping(sourceLocation, generatedLocation); var lineMapping = new LineMapping(sourceLocation, generatedLocation);
Context.LineMappings.Add(lineMapping); Context.LineMappings.Add(lineMapping);
@ -337,7 +337,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution
private void RenderTagHelperAttributeInline( private void RenderTagHelperAttributeInline(
RazorIRNode node, RazorIRNode node,
MappingLocation documentLocation) SourceSpan documentLocation)
{ {
if (node is SetTagHelperPropertyIRNode || node is CSharpExpressionIRNode) if (node is SetTagHelperPropertyIRNode || node is CSharpExpressionIRNode)
{ {
@ -348,7 +348,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution
} }
else if (node is HtmlContentIRNode) else if (node is HtmlContentIRNode)
{ {
if (node.SourceRange != null) if (node.Source != null)
{ {
AddLineMappingFor(node); AddLineMappingFor(node);
} }
@ -357,7 +357,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution
} }
else if (node is CSharpTokenIRNode) else if (node is CSharpTokenIRNode)
{ {
if (node.SourceRange != null) if (node.Source != null)
{ {
AddLineMappingFor(node); AddLineMappingFor(node);
} }
@ -367,17 +367,17 @@ namespace Microsoft.AspNetCore.Razor.Evolution
else if (node is CSharpStatementIRNode) else if (node is CSharpStatementIRNode)
{ {
Context.ErrorSink.OnError( Context.ErrorSink.OnError(
new SourceLocation(documentLocation.AbsoluteIndex, documentLocation.CharacterIndex, documentLocation.ContentLength), new SourceLocation(documentLocation.AbsoluteIndex, documentLocation.CharacterIndex, documentLocation.Length),
LegacyResources.TagHelpers_CodeBlocks_NotSupported_InAttributes, LegacyResources.TagHelpers_CodeBlocks_NotSupported_InAttributes,
documentLocation.ContentLength); documentLocation.Length);
} }
else if (node is TemplateIRNode) else if (node is TemplateIRNode)
{ {
var attributeValueNode = (SetTagHelperPropertyIRNode)node.Parent; var attributeValueNode = (SetTagHelperPropertyIRNode)node.Parent;
Context.ErrorSink.OnError( Context.ErrorSink.OnError(
new SourceLocation(documentLocation.AbsoluteIndex, documentLocation.CharacterIndex, documentLocation.ContentLength), new SourceLocation(documentLocation.AbsoluteIndex, documentLocation.CharacterIndex, documentLocation.Length),
LegacyResources.FormatTagHelpers_InlineMarkupBlocks_NotSupported_InAttributes(attributeValueNode.Descriptor.TypeName), LegacyResources.FormatTagHelpers_InlineMarkupBlocks_NotSupported_InAttributes(attributeValueNode.Descriptor.TypeName),
documentLocation.ContentLength); documentLocation.Length);
} }
} }
} }

View File

@ -76,7 +76,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution
Name = chunkGenerator.Name, Name = chunkGenerator.Name,
Prefix = chunkGenerator.Prefix, Prefix = chunkGenerator.Prefix,
Suffix = chunkGenerator.Suffix, Suffix = chunkGenerator.Suffix,
SourceRange = BuildSourceRangeFromNode(block), Source = BuildSourceRangeFromNode(block),
}); });
} }
@ -94,7 +94,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution
Builder.Push(new CSharpAttributeValueIRNode() Builder.Push(new CSharpAttributeValueIRNode()
{ {
Prefix = chunkGenerator.Prefix, Prefix = chunkGenerator.Prefix,
SourceRange = BuildSourceRangeFromNode(block), Source = BuildSourceRangeFromNode(block),
}); });
} }
@ -109,7 +109,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution
{ {
Prefix = chunkGenerator.Prefix, Prefix = chunkGenerator.Prefix,
Content = chunkGenerator.Value, Content = chunkGenerator.Value,
SourceRange = BuildSourceRangeFromNode(span), Source = BuildSourceRangeFromNode(span),
}); });
} }
@ -125,19 +125,19 @@ namespace Microsoft.AspNetCore.Razor.Evolution
{ {
var sourceRangeStart = templateNode var sourceRangeStart = templateNode
.Children .Children
.FirstOrDefault(child => child.SourceRange != null) .FirstOrDefault(child => child.Source != null)
?.SourceRange; ?.Source;
if (sourceRangeStart != null) if (sourceRangeStart != null)
{ {
var contentLength = templateNode.Children.Sum(child => child.SourceRange?.ContentLength ?? 0); var contentLength = templateNode.Children.Sum(child => child.Source?.Length ?? 0);
templateNode.SourceRange = new MappingLocation( templateNode.Source = new SourceSpan(
sourceRangeStart.AbsoluteIndex, sourceRangeStart.Value.FilePath ?? _codeDocument.Source.Filename,
sourceRangeStart.LineIndex, sourceRangeStart.Value.AbsoluteIndex,
sourceRangeStart.CharacterIndex, sourceRangeStart.Value.LineIndex,
contentLength, sourceRangeStart.Value.CharacterIndex,
sourceRangeStart.FilePath ?? _codeDocument.Source.Filename); contentLength);
} }
} }
} }
@ -161,19 +161,19 @@ namespace Microsoft.AspNetCore.Razor.Evolution
{ {
var sourceRangeStart = expressionNode var sourceRangeStart = expressionNode
.Children .Children
.FirstOrDefault(child => child.SourceRange != null) .FirstOrDefault(child => child.Source != null)
?.SourceRange; ?.Source;
if (sourceRangeStart != null) if (sourceRangeStart != null)
{ {
var contentLength = expressionNode.Children.Sum(child => child.SourceRange?.ContentLength ?? 0); var contentLength = expressionNode.Children.Sum(child => child.Source?.Length ?? 0);
expressionNode.SourceRange = new MappingLocation( expressionNode.Source = new SourceSpan(
sourceRangeStart.AbsoluteIndex, sourceRangeStart.Value.FilePath ?? _codeDocument.Source.Filename,
sourceRangeStart.LineIndex, sourceRangeStart.Value.AbsoluteIndex,
sourceRangeStart.CharacterIndex, sourceRangeStart.Value.LineIndex,
contentLength, sourceRangeStart.Value.CharacterIndex,
sourceRangeStart.FilePath ?? _codeDocument.Source.Filename); contentLength);
} }
} }
} }
@ -195,7 +195,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution
Builder.Add(new CSharpTokenIRNode() Builder.Add(new CSharpTokenIRNode()
{ {
Content = span.Content, Content = span.Content,
SourceRange = BuildSourceRangeFromNode(span), Source = BuildSourceRangeFromNode(span),
}); });
} }
@ -204,7 +204,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution
Builder.Add(new CSharpStatementIRNode() Builder.Add(new CSharpStatementIRNode()
{ {
Content = span.Content, Content = span.Content,
SourceRange = BuildSourceRangeFromNode(span), Source = BuildSourceRangeFromNode(span),
}); });
} }
@ -227,19 +227,25 @@ namespace Microsoft.AspNetCore.Razor.Evolution
{ {
var existingHtmlContent = (HtmlContentIRNode)currentChildren[currentChildren.Count - 1]; var existingHtmlContent = (HtmlContentIRNode)currentChildren[currentChildren.Count - 1];
existingHtmlContent.Content = string.Concat(existingHtmlContent.Content, span.Content); existingHtmlContent.Content = string.Concat(existingHtmlContent.Content, span.Content);
existingHtmlContent.SourceRange = new MappingLocation(
existingHtmlContent.SourceRange.AbsoluteIndex, if (existingHtmlContent.Source != null)
existingHtmlContent.SourceRange.LineIndex, {
existingHtmlContent.SourceRange.CharacterIndex, var contentLength = existingHtmlContent.Source.Value.Length + span.Content.Length;
existingHtmlContent.SourceRange.ContentLength + span.Content.Length,
existingHtmlContent.SourceRange.FilePath); existingHtmlContent.Source = new SourceSpan(
existingHtmlContent.Source.Value.FilePath ?? _codeDocument.Source.Filename,
existingHtmlContent.Source.Value.AbsoluteIndex,
existingHtmlContent.Source.Value.LineIndex,
existingHtmlContent.Source.Value.CharacterIndex,
contentLength);
}
} }
else else
{ {
Builder.Add(new HtmlContentIRNode() Builder.Add(new HtmlContentIRNode()
{ {
Content = span.Content, Content = span.Content,
SourceRange = BuildSourceRangeFromNode(span), Source = BuildSourceRangeFromNode(span),
}); });
} }
} }
@ -254,7 +260,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution
Builder.Add(new UsingStatementIRNode() Builder.Add(new UsingStatementIRNode()
{ {
Content = namespaceImport, Content = namespaceImport,
SourceRange = BuildSourceRangeFromNode(span), Source = BuildSourceRangeFromNode(span),
}); });
} }
} }
@ -265,7 +271,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution
{ {
Content = span.Content, Content = span.Content,
Descriptor = chunkGenerator.Descriptor, Descriptor = chunkGenerator.Descriptor,
SourceRange = BuildSourceRangeFromNode(span), Source = BuildSourceRangeFromNode(span),
}); });
} }
@ -388,7 +394,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution
TagHelperTypeName = associatedDescriptor.TypeName, TagHelperTypeName = associatedDescriptor.TypeName,
Descriptor = associatedAttributeDescriptor, Descriptor = associatedAttributeDescriptor,
ValueStyle = attribute.ValueStyle, ValueStyle = attribute.ValueStyle,
SourceRange = BuildSourceRangeFromNode(attributeValueNode) Source = BuildSourceRangeFromNode(attributeValueNode)
}; };
Builder.Push(setTagHelperProperty); Builder.Push(setTagHelperProperty);
@ -419,16 +425,15 @@ namespace Microsoft.AspNetCore.Razor.Evolution
Builder.Add(new ExecuteTagHelpersIRNode()); Builder.Add(new ExecuteTagHelpersIRNode());
} }
private MappingLocation BuildSourceRangeFromNode(SyntaxTreeNode node) private SourceSpan BuildSourceRangeFromNode(SyntaxTreeNode node)
{ {
var location = node.Start; var location = node.Start;
var sourceRange = new MappingLocation( var sourceRange = new SourceSpan(
location.AbsoluteIndex, node.Start.FilePath ?? _codeDocument.Source.Filename,
location.LineIndex, node.Start.AbsoluteIndex,
location.CharacterIndex, node.Start.LineIndex,
node.Length, node.Start.CharacterIndex,
location.FilePath ?? _codeDocument.Source.Filename); node.Length);
return sourceRange; return sourceRange;
} }
} }

View File

@ -109,10 +109,10 @@ namespace Microsoft.AspNetCore.Razor.Evolution
public override void VisitCSharpExpression(CSharpExpressionIRNode node) public override void VisitCSharpExpression(CSharpExpressionIRNode node)
{ {
IDisposable linePragmaScope = null; IDisposable linePragmaScope = null;
if (node.SourceRange != null) if (node.Source != null)
{ {
linePragmaScope = new LinePragmaWriter(Context.Writer, node.SourceRange); linePragmaScope = new LinePragmaWriter(Context.Writer, node.Source.Value);
var padding = BuildOffsetPadding(Context.RenderingConventions.StartWriteMethod.Length, node.SourceRange, Context); var padding = BuildOffsetPadding(Context.RenderingConventions.StartWriteMethod.Length, node.Source.Value, Context);
Context.Writer.Write(padding); Context.Writer.Write(padding);
} }
@ -135,8 +135,8 @@ namespace Microsoft.AspNetCore.Razor.Evolution
var valuePieceCount = node var valuePieceCount = node
.Children .Children
.Count(child => child is HtmlAttributeValueIRNode || child is CSharpAttributeValueIRNode); .Count(child => child is HtmlAttributeValueIRNode || child is CSharpAttributeValueIRNode);
var prefixLocation = node.SourceRange.AbsoluteIndex; var prefixLocation = node.Source.Value.AbsoluteIndex;
var suffixLocation = node.SourceRange.AbsoluteIndex + node.SourceRange.ContentLength - node.Suffix.Length; var suffixLocation = node.Source.Value.AbsoluteIndex + node.Source.Value.Length - node.Suffix.Length;
Context.Writer Context.Writer
.Write(Context.RenderingConventions.StartBeginWriteAttributeMethod) .Write(Context.RenderingConventions.StartBeginWriteAttributeMethod)
.WriteStringLiteral(node.Name) .WriteStringLiteral(node.Name)
@ -161,9 +161,9 @@ namespace Microsoft.AspNetCore.Razor.Evolution
public override void VisitHtmlAttributeValue(HtmlAttributeValueIRNode node) public override void VisitHtmlAttributeValue(HtmlAttributeValueIRNode node)
{ {
var prefixLocation = node.SourceRange.AbsoluteIndex; var prefixLocation = node.Source.Value.AbsoluteIndex;
var valueLocation = node.SourceRange.AbsoluteIndex + node.Prefix.Length; var valueLocation = node.Source.Value.AbsoluteIndex + node.Prefix.Length;
var valueLength = node.SourceRange.ContentLength; var valueLength = node.Source.Value.Length;
Context.Writer Context.Writer
.Write(Context.RenderingConventions.StartWriteAttributeValueMethod) .Write(Context.RenderingConventions.StartWriteAttributeValueMethod)
.WriteStringLiteral(node.Prefix) .WriteStringLiteral(node.Prefix)
@ -185,10 +185,10 @@ namespace Microsoft.AspNetCore.Razor.Evolution
const string ValueWriterName = "__razor_attribute_value_writer"; const string ValueWriterName = "__razor_attribute_value_writer";
var expressionValue = node.Children.FirstOrDefault() as CSharpExpressionIRNode; var expressionValue = node.Children.FirstOrDefault() as CSharpExpressionIRNode;
var linePragma = expressionValue != null ? new LinePragmaWriter(Context.Writer, node.SourceRange) : null; var linePragma = expressionValue != null ? new LinePragmaWriter(Context.Writer, node.Source.Value) : null;
var prefixLocation = node.SourceRange.AbsoluteIndex; var prefixLocation = node.Source.Value.AbsoluteIndex;
var valueLocation = node.SourceRange.AbsoluteIndex + node.Prefix.Length; var valueLocation = node.Source.Value.AbsoluteIndex + node.Prefix.Length;
var valueLength = node.SourceRange.ContentLength - node.Prefix.Length; var valueLength = node.Source.Value.Length - node.Prefix.Length;
Context.Writer Context.Writer
.Write(Context.RenderingConventions.StartWriteAttributeValueMethod) .Write(Context.RenderingConventions.StartWriteAttributeValueMethod)
.WriteStringLiteral(node.Prefix) .WriteStringLiteral(node.Prefix)
@ -237,11 +237,11 @@ namespace Microsoft.AspNetCore.Razor.Evolution
return; return;
} }
if (node.SourceRange != null) if (node.Source != null)
{ {
using (new LinePragmaWriter(Context.Writer, node.SourceRange)) using (new LinePragmaWriter(Context.Writer, node.Source.Value))
{ {
var padding = BuildOffsetPadding(0, node.SourceRange, Context); var padding = BuildOffsetPadding(0, node.Source.Value, Context);
Context.Writer Context.Writer
.Write(padding) .Write(padding)
.WriteLine(node.Content); .WriteLine(node.Content);
@ -499,7 +499,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution
} }
else else
{ {
using (new LinePragmaWriter(Context.Writer, node.SourceRange)) using (new LinePragmaWriter(Context.Writer, node.Source.Value))
{ {
Context.Writer.WriteStartAssignment(propertyValueAccessor); Context.Writer.WriteStartAssignment(propertyValueAccessor);
@ -513,7 +513,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution
.Write("."); .Write(".");
} }
RenderTagHelperAttributeInline(node, node.SourceRange); RenderTagHelperAttributeInline(node, node.Source.Value);
Context.Writer.WriteLine(";"); Context.Writer.WriteLine(";");
} }
@ -698,7 +698,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution
private void RenderTagHelperAttributeInline( private void RenderTagHelperAttributeInline(
RazorIRNode node, RazorIRNode node,
MappingLocation documentLocation) SourceSpan documentLocation)
{ {
if (node is SetTagHelperPropertyIRNode || node is CSharpExpressionIRNode) if (node is SetTagHelperPropertyIRNode || node is CSharpExpressionIRNode)
{ {
@ -718,17 +718,17 @@ namespace Microsoft.AspNetCore.Razor.Evolution
else if (node is CSharpStatementIRNode) else if (node is CSharpStatementIRNode)
{ {
Context.ErrorSink.OnError( Context.ErrorSink.OnError(
new SourceLocation(documentLocation.AbsoluteIndex, documentLocation.CharacterIndex, documentLocation.ContentLength), new SourceLocation(documentLocation.AbsoluteIndex, documentLocation.CharacterIndex, documentLocation.Length),
LegacyResources.TagHelpers_CodeBlocks_NotSupported_InAttributes, LegacyResources.TagHelpers_CodeBlocks_NotSupported_InAttributes,
documentLocation.ContentLength); documentLocation.Length);
} }
else if (node is TemplateIRNode) else if (node is TemplateIRNode)
{ {
var attributeValueNode = (SetTagHelperPropertyIRNode)node.Parent; var attributeValueNode = (SetTagHelperPropertyIRNode)node.Parent;
Context.ErrorSink.OnError( Context.ErrorSink.OnError(
new SourceLocation(documentLocation.AbsoluteIndex, documentLocation.CharacterIndex, documentLocation.ContentLength), new SourceLocation(documentLocation.AbsoluteIndex, documentLocation.CharacterIndex, documentLocation.Length),
LegacyResources.FormatTagHelpers_InlineMarkupBlocks_NotSupported_InAttributes(attributeValueNode.Descriptor.TypeName), LegacyResources.FormatTagHelpers_InlineMarkupBlocks_NotSupported_InAttributes(attributeValueNode.Descriptor.TypeName),
documentLocation.ContentLength); documentLocation.Length);
} }
} }
} }

View File

@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public string VariableName { get; set; } public string VariableName { get; set; }

View File

@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public string Name { get; set; } public string Name { get; set; }

View File

@ -3,7 +3,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.AspNetCore.Razor.Evolution.Legacy;
namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
{ {
@ -13,7 +12,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public string Prefix { get; set; } public string Prefix { get; set; }

View File

@ -3,7 +3,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.AspNetCore.Razor.Evolution.Legacy;
namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
{ {
@ -13,7 +12,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public override void Accept(RazorIRNodeVisitor visitor) public override void Accept(RazorIRNodeVisitor visitor)
{ {

View File

@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public string Content { get; set; } public string Content { get; set; }

View File

@ -3,7 +3,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.AspNetCore.Razor.Evolution.Legacy;
namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
{ {
@ -13,7 +12,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public string Content { get; set; } public string Content { get; set; }

View File

@ -4,7 +4,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
using Microsoft.AspNetCore.Razor.Evolution.Legacy;
namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
{ {
@ -14,7 +13,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public string Bytes { get; set; } public string Bytes { get; set; }

View File

@ -3,7 +3,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.AspNetCore.Razor.Evolution.Legacy;
namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
{ {
@ -13,7 +12,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public string AccessModifier { get; set; } public string AccessModifier { get; set; }

View File

@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public string TagHelperTypeName { get; set; } public string TagHelperTypeName { get; set; }

View File

@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public string VariableName { get; set; } public string VariableName { get; set; }

View File

@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public string VariableName { get; set; } public string VariableName { get; set; }

View File

@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public ISet<string> UsedTagHelperTypeNames { get; set; } = new HashSet<string>(StringComparer.Ordinal); public ISet<string> UsedTagHelperTypeNames { get; set; } = new HashSet<string>(StringComparer.Ordinal);

View File

@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public string Name { get; set; } public string Name { get; set; }

View File

@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public string Content { get; set; } public string Content { get; set; }

View File

@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public override void Accept(RazorIRNodeVisitor visitor) public override void Accept(RazorIRNodeVisitor visitor)
{ {

View File

@ -3,7 +3,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.AspNetCore.Razor.Evolution.Legacy;
namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
{ {
@ -13,7 +12,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public override void Accept(RazorIRNodeVisitor visitor) public override void Accept(RazorIRNodeVisitor visitor)
{ {

View File

@ -3,7 +3,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.AspNetCore.Razor.Evolution.Legacy;
namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
{ {
@ -13,7 +12,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public string Name { get; set; } public string Name { get; set; }

View File

@ -3,7 +3,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.AspNetCore.Razor.Evolution.Legacy;
namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
{ {
@ -13,7 +12,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public string Prefix { get; set; } public string Prefix { get; set; }

View File

@ -3,7 +3,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.AspNetCore.Razor.Evolution.Legacy;
namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
{ {
@ -15,7 +14,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public override void Accept(RazorIRNodeVisitor visitor) public override void Accept(RazorIRNodeVisitor visitor)
{ {

View File

@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public string TagName { get; set; } public string TagName { get; set; }

View File

@ -3,7 +3,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.AspNetCore.Razor.Evolution.Legacy;
namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
{ {
@ -13,7 +12,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public string Content { get; set; } public string Content { get; set; }

View File

@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.AspNetCore.Razor.Evolution.Legacy;
namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
{ {
@ -14,7 +13,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public abstract RazorIRNode Parent { get; set; } public abstract RazorIRNode Parent { get; set; }
internal abstract MappingLocation SourceRange { get; set; } public abstract SourceSpan? Source { get; set; }
public abstract void Accept(RazorIRNodeVisitor visitor); public abstract void Accept(RazorIRNodeVisitor visitor);

View File

@ -3,7 +3,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.AspNetCore.Razor.Evolution.Legacy;
namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
{ {
@ -13,7 +12,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public string AccessModifier { get; set; } public string AccessModifier { get; set; }

View File

@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public string VariableName { get; set; } public string VariableName { get; set; }

View File

@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public string TagHelperTypeName { get; set; } public string TagHelperTypeName { get; set; }

View File

@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public override void Accept(RazorIRNodeVisitor visitor) public override void Accept(RazorIRNodeVisitor visitor)
{ {

View File

@ -3,7 +3,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.AspNetCore.Razor.Evolution.Legacy;
namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
{ {
@ -13,7 +12,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public override void Accept(RazorIRNodeVisitor visitor) public override void Accept(RazorIRNodeVisitor visitor)
{ {

View File

@ -3,7 +3,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.AspNetCore.Razor.Evolution.Legacy;
namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
{ {
@ -13,7 +12,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public string Content { get; set; } public string Content { get; set; }

View File

@ -191,7 +191,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
/// <param name="location">The location to generate the line pragma for.</param> /// <param name="location">The location to generate the line pragma for.</param>
/// <param name="file">The file to generate the line pragma for.</param> /// <param name="file">The file to generate the line pragma for.</param>
/// <returns>The current instance of <see cref="CSharpCodeWriter"/>.</returns> /// <returns>The current instance of <see cref="CSharpCodeWriter"/>.</returns>
public CSharpCodeWriter WriteLineNumberDirective(MappingLocation location, string file) public CSharpCodeWriter WriteLineNumberDirective(SourceSpan location, string file)
{ {
if (location.FilePath != null) if (location.FilePath != null)
{ {

View File

@ -8,15 +8,15 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{ {
internal class LineMapping internal class LineMapping
{ {
public LineMapping(MappingLocation documentLocation, MappingLocation generatedLocation) public LineMapping(SourceSpan documentLocation, SourceSpan generatedLocation)
{ {
DocumentLocation = documentLocation; DocumentLocation = documentLocation;
GeneratedLocation = generatedLocation; GeneratedLocation = generatedLocation;
} }
public MappingLocation DocumentLocation { get; } public SourceSpan DocumentLocation { get; }
public MappingLocation GeneratedLocation { get; } public SourceSpan GeneratedLocation { get; }
public override bool Equals(object obj) public override bool Equals(object obj)
{ {

View File

@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution
} }
} }
protected static int CalculateExpressionPadding(MappingLocation sourceRange, CSharpRenderingContext context) protected static int CalculateExpressionPadding(SourceSpan sourceRange, CSharpRenderingContext context)
{ {
var spaceCount = 0; var spaceCount = 0;
for (var i = sourceRange.AbsoluteIndex - 1; i >= 0; i--) for (var i = sourceRange.AbsoluteIndex - 1; i >= 0; i--)
@ -48,7 +48,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution
return spaceCount; return spaceCount;
} }
protected static string BuildOffsetPadding(int generatedOffset, MappingLocation sourceRange, CSharpRenderingContext context) protected static string BuildOffsetPadding(int generatedOffset, SourceSpan sourceRange, CSharpRenderingContext context)
{ {
var basePadding = CalculateExpressionPadding(sourceRange, context); var basePadding = CalculateExpressionPadding(sourceRange, context);
var resolvedPadding = Math.Max(basePadding - generatedOffset, 0); var resolvedPadding = Math.Max(basePadding - generatedOffset, 0);
@ -89,7 +89,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution
private readonly CSharpCodeWriter _writer; private readonly CSharpCodeWriter _writer;
private readonly int _startIndent; private readonly int _startIndent;
public LinePragmaWriter(CSharpCodeWriter writer, MappingLocation documentLocation) public LinePragmaWriter(CSharpCodeWriter writer, SourceSpan documentLocation)
{ {
if (writer == null) if (writer == null)
{ {

View File

@ -1,10 +1,8 @@
using System; // Copyright (c) .NET Foundation. All rights reserved.
using System.Collections.Generic;
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using Microsoft.AspNetCore.Razor.Evolution.Intermediate; using Microsoft.AspNetCore.Razor.Evolution.Intermediate;
using Microsoft.AspNetCore.Razor.Evolution.Legacy;
namespace Microsoft.AspNetCore.Razor.Evolution namespace Microsoft.AspNetCore.Razor.Evolution
{ {
@ -84,7 +82,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public void AddToMethodBody(RazorIRNode node) public void AddToMethodBody(RazorIRNode node)
{ {

View File

@ -5,29 +5,25 @@ using System;
using System.Globalization; using System.Globalization;
using Microsoft.Extensions.Internal; using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Razor.Evolution.Legacy namespace Microsoft.AspNetCore.Razor.Evolution
{ {
internal class MappingLocation public struct SourceSpan : IEquatable<SourceSpan>
{ {
public MappingLocation() public SourceSpan(SourceLocation location, int contentLength)
: this(location.FilePath, location.AbsoluteIndex, location.LineIndex, location.CharacterIndex, contentLength)
{ {
} }
public MappingLocation(SourceLocation location, int contentLength) public SourceSpan(string filePath, int absoluteIndex, int lineIndex, int characterIndex, int length)
: this (location.AbsoluteIndex, location.LineIndex, location.CharacterIndex, contentLength, location.FilePath)
{
}
public MappingLocation(int absoluteIndex, int lineIndex, int characterIndex, int contentLength, string filePath)
{ {
AbsoluteIndex = absoluteIndex; AbsoluteIndex = absoluteIndex;
LineIndex = lineIndex; LineIndex = lineIndex;
CharacterIndex = characterIndex; CharacterIndex = characterIndex;
ContentLength = contentLength; Length = length;
FilePath = filePath; FilePath = filePath;
} }
public int ContentLength { get; } public int Length { get; }
public int AbsoluteIndex { get; } public int AbsoluteIndex { get; }
@ -37,31 +33,37 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
public string FilePath { get; } public string FilePath { get; }
public bool Equals(SourceSpan other)
{
return
string.Equals(FilePath, other.FilePath, StringComparison.Ordinal) &&
AbsoluteIndex == other.AbsoluteIndex &&
LineIndex == other.LineIndex &&
CharacterIndex == other.CharacterIndex &&
Length == other.Length;
}
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
var other = obj as MappingLocation; var other = obj as SourceSpan?;
if (ReferenceEquals(other, null)) if (ReferenceEquals(other, null))
{ {
return false; return false;
} }
return string.Equals(FilePath, other.FilePath, StringComparison.Ordinal) && return Equals(other.Value);
AbsoluteIndex == other.AbsoluteIndex &&
ContentLength == other.ContentLength &&
LineIndex == other.LineIndex &&
CharacterIndex == other.CharacterIndex;
} }
public override int GetHashCode() public override int GetHashCode()
{ {
var hashCodeCombiner = HashCodeCombiner.Start(); var hash = HashCodeCombiner.Start();
hashCodeCombiner.Add(FilePath, StringComparer.Ordinal); hash.Add(FilePath, StringComparer.Ordinal);
hashCodeCombiner.Add(AbsoluteIndex); hash.Add(AbsoluteIndex);
hashCodeCombiner.Add(ContentLength); hash.Add(LineIndex);
hashCodeCombiner.Add(LineIndex); hash.Add(CharacterIndex);
hashCodeCombiner.Add(CharacterIndex); hash.Add(Length);
return hashCodeCombiner; return hash;
} }
public override string ToString() public override string ToString()
@ -71,11 +73,11 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
AbsoluteIndex, AbsoluteIndex,
LineIndex, LineIndex,
CharacterIndex, CharacterIndex,
ContentLength, Length,
FilePath); FilePath);
} }
public static bool operator ==(MappingLocation left, MappingLocation right) public static bool operator ==(SourceSpan left, SourceSpan right)
{ {
if (ReferenceEquals(left, right)) if (ReferenceEquals(left, right))
{ {
@ -91,7 +93,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
return left.Equals(right); return left.Equals(right);
} }
public static bool operator !=(MappingLocation left, MappingLocation right) public static bool operator !=(SourceSpan left, SourceSpan right)
{ {
if (ReferenceEquals(left, right)) if (ReferenceEquals(left, right))
{ {

View File

@ -31,13 +31,13 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests
return builder.ToString(); return builder.ToString();
} }
private static void AppendMappingLocation(StringBuilder builder, MappingLocation location, string content) private static void AppendMappingLocation(StringBuilder builder, SourceSpan location, string content)
{ {
builder builder
.AppendLine(location.ToString()) .AppendLine(location.ToString())
.Append("|"); .Append("|");
for (var i = 0; i < location.ContentLength; i++) for (var i = 0; i < location.Length; i++)
{ {
builder.Append(content[location.AbsoluteIndex + i]); builder.Append(content[location.AbsoluteIndex + i]);
} }

View File

@ -190,9 +190,9 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests
protected void WriteSourceRange(RazorIRNode node) protected void WriteSourceRange(RazorIRNode node)
{ {
if (node.SourceRange != null) if (node.Source != null)
{ {
var sourceRange = node.SourceRange; var sourceRange = node.Source.Value;
_writer.Write("("); _writer.Write("(");
_writer.Write(sourceRange.AbsoluteIndex); _writer.Write(sourceRange.AbsoluteIndex);
_writer.Write(":"); _writer.Write(":");
@ -200,7 +200,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests
_writer.Write(","); _writer.Write(",");
_writer.Write(sourceRange.CharacterIndex); _writer.Write(sourceRange.CharacterIndex);
_writer.Write(" ["); _writer.Write(" [");
_writer.Write(sourceRange.ContentLength); _writer.Write(sourceRange.Length);
_writer.Write("] "); _writer.Write("] ");
var fileName = sourceRange.FilePath.Substring(sourceRange.FilePath.LastIndexOf('/') + 1); var fileName = sourceRange.FilePath.Substring(sourceRange.FilePath.LastIndexOf('/') + 1);

View File

@ -218,7 +218,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public override void Accept(RazorIRNodeVisitor visitor) public override void Accept(RazorIRNodeVisitor visitor)
{ {

View File

@ -78,7 +78,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public override void Accept(RazorIRNodeVisitor visitor) public override void Accept(RazorIRNodeVisitor visitor)
{ {
@ -97,7 +97,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public override void Accept(RazorIRNodeVisitor visitor) public override void Accept(RazorIRNodeVisitor visitor)
{ {
@ -116,7 +116,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public override void Accept(RazorIRNodeVisitor visitor) public override void Accept(RazorIRNodeVisitor visitor)
{ {

View File

@ -3,7 +3,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.AspNetCore.Razor.Evolution.Legacy;
using Xunit; using Xunit;
namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
@ -75,7 +74,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Intermediate
public override RazorIRNode Parent { get; set; } public override RazorIRNode Parent { get; set; }
internal override MappingLocation SourceRange { get; set; } public override SourceSpan? Source { get; set; }
public override void Accept(RazorIRNodeVisitor visitor) public override void Accept(RazorIRNodeVisitor visitor)
{ {

View File

@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
var writer = new CSharpCodeWriter(); var writer = new CSharpCodeWriter();
var expected = $"#line 5 \"{filePath}\"" + writer.NewLine; var expected = $"#line 5 \"{filePath}\"" + writer.NewLine;
var sourceLocation = new SourceLocation(10, 4, 3); var sourceLocation = new SourceLocation(10, 4, 3);
var mappingLocation = new MappingLocation(sourceLocation, 9); var mappingLocation = new SourceSpan(sourceLocation, 9);
// Act // Act
writer.WriteLineNumberDirective(mappingLocation, filePath); writer.WriteLineNumberDirective(mappingLocation, filePath);
@ -36,7 +36,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
var writer = new CSharpCodeWriter(); var writer = new CSharpCodeWriter();
var expected = $"#line 5 \"{sourceLocationFilePath}\"" + writer.NewLine; var expected = $"#line 5 \"{sourceLocationFilePath}\"" + writer.NewLine;
var sourceLocation = new SourceLocation(sourceLocationFilePath, 10, 4, 3); var sourceLocation = new SourceLocation(sourceLocationFilePath, 10, 4, 3);
var mappingLocation = new MappingLocation(sourceLocation, 9); var mappingLocation = new SourceSpan(sourceLocation, 9);
// Act // Act
writer.WriteLineNumberDirective(mappingLocation, filePath); writer.WriteLineNumberDirective(mappingLocation, filePath);

View File

@ -2,23 +2,23 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Xunit; using Xunit;
using Microsoft.AspNetCore.Razor.Evolution.Legacy;
namespace Microsoft.AspNetCore.Razor.Evolution.Legacy namespace Microsoft.AspNetCore.Razor.Evolution
{ {
public class LineMappingTest public class SourceSpanTest
{ {
[Fact] [Fact]
public void GeneratedCodeMappingsAreEqualIfDataIsEqual() public void GeneratedCodeMappingsAreEqualIfDataIsEqual()
{ {
// Arrange // Arrange
var left = new LineMapping( var left = new LineMapping(
new MappingLocation(new SourceLocation(1, 2, 3), 4), new SourceSpan(new SourceLocation(1, 2, 3), 4),
new MappingLocation(new SourceLocation(5, 6, 7), 8) new SourceSpan(new SourceLocation(5, 6, 7), 8));
);
var right = new LineMapping( var right = new LineMapping(
new MappingLocation(new SourceLocation(1, 2, 3), 4), new SourceSpan(new SourceLocation(1, 2, 3), 4),
new MappingLocation(new SourceLocation(5, 6, 7), 8) new SourceSpan(new SourceLocation(5, 6, 7), 8));
);
// Assert // Assert
Assert.True(left == right); Assert.True(left == right);
@ -32,13 +32,12 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{ {
// Arrange // Arrange
var left = new LineMapping( var left = new LineMapping(
new MappingLocation(new SourceLocation(1, 2, 3), 4), new SourceSpan(new SourceLocation(1, 2, 3), 4),
new MappingLocation(new SourceLocation(5, 6, 7), 8) new SourceSpan(new SourceLocation(5, 6, 7), 8));
);
var right = new LineMapping( var right = new LineMapping(
new MappingLocation(new SourceLocation(1, 2, 3), 5), new SourceSpan(new SourceLocation(1, 2, 3), 5),
new MappingLocation(new SourceLocation(5, 6, 7), 9) new SourceSpan(new SourceLocation(5, 6, 7), 9));
);
// Assert // Assert
AssertNotEqual(left, right); AssertNotEqual(left, right);
@ -49,13 +48,12 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{ {
// Arrange // Arrange
var left = new LineMapping( var left = new LineMapping(
new MappingLocation(new SourceLocation(1, 2, 3), 4), new SourceSpan(new SourceLocation(1, 2, 3), 4),
new MappingLocation(new SourceLocation(5, 6, 7), 8) new SourceSpan(new SourceLocation(5, 6, 7), 8));
);
var right = new LineMapping( var right = new LineMapping(
new MappingLocation(new SourceLocation(1, 2, 3), 4), new SourceSpan(new SourceLocation(1, 2, 3), 4),
new MappingLocation(new SourceLocation(5, 6, 8), 8) new SourceSpan(new SourceLocation(5, 6, 8), 8));
);
// Assert // Assert
AssertNotEqual(left, right); AssertNotEqual(left, right);
@ -66,13 +64,12 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{ {
// Arrange // Arrange
var left = new LineMapping( var left = new LineMapping(
new MappingLocation(new SourceLocation(1, 2, 3), 4), new SourceSpan(new SourceLocation(1, 2, 3), 4),
new MappingLocation(new SourceLocation(5, 6, 8), 8) new SourceSpan(new SourceLocation(5, 6, 8), 8));
);
var right = new LineMapping( var right = new LineMapping(
new MappingLocation(new SourceLocation(1, 2, 3), 4), new SourceSpan(new SourceLocation(1, 2, 3), 4),
new MappingLocation(new SourceLocation(5, 6, 7), 8) new SourceSpan(new SourceLocation(5, 6, 7), 8));
);
// Assert // Assert
AssertNotEqual(left, right); AssertNotEqual(left, right);
@ -83,13 +80,12 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{ {
// Arrange // Arrange
var left = new LineMapping( var left = new LineMapping(
new MappingLocation(new SourceLocation(1, 2, 3), 4), new SourceSpan(new SourceLocation(1, 2, 3), 4),
new MappingLocation(new SourceLocation(5, 5, 7), 8) new SourceSpan(new SourceLocation(5, 5, 7), 8));
);
var right = new LineMapping( var right = new LineMapping(
new MappingLocation(new SourceLocation(1, 1, 3), 4), new SourceSpan(new SourceLocation(1, 1, 3), 4),
new MappingLocation(new SourceLocation(5, 6, 7), 8) new SourceSpan(new SourceLocation(5, 6, 7), 8));
);
// Assert // Assert
AssertNotEqual(left, right); AssertNotEqual(left, right);
@ -100,13 +96,12 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
{ {
// Arrange // Arrange
var left = new LineMapping( var left = new LineMapping(
new MappingLocation(new SourceLocation(1, 2, 3), 4), new SourceSpan(new SourceLocation(1, 2, 3), 4),
new MappingLocation(new SourceLocation(4, 6, 7), 8) new SourceSpan(new SourceLocation(4, 6, 7), 8));
);
var right = new LineMapping( var right = new LineMapping(
new MappingLocation(new SourceLocation(1, 2, 3), 4), new SourceSpan(new SourceLocation(1, 2, 3), 4),
new MappingLocation(new SourceLocation(5, 6, 7), 9) new SourceSpan(new SourceLocation(5, 6, 7), 9));
);
// Assert // Assert
AssertNotEqual(left, right); AssertNotEqual(left, right);