diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/LineMapping.cs b/src/Microsoft.AspNetCore.Razor.Evolution/LineMapping.cs similarity index 67% rename from src/Microsoft.AspNetCore.Razor.Evolution/Legacy/LineMapping.cs rename to src/Microsoft.AspNetCore.Razor.Evolution/LineMapping.cs index 6609eecc12..07c82be32f 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/Legacy/LineMapping.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/LineMapping.cs @@ -1,40 +1,46 @@ // 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. +using System; using System.Globalization; using Microsoft.Extensions.Internal; -namespace Microsoft.AspNetCore.Razor.Evolution.Legacy +namespace Microsoft.AspNetCore.Razor.Evolution { - internal class LineMapping + public sealed class LineMapping : IEquatable { - public LineMapping(SourceSpan documentLocation, SourceSpan generatedLocation) + public LineMapping(SourceSpan originalSourceSpan, SourceSpan generatedSourceSpan) { - DocumentLocation = documentLocation; - GeneratedLocation = generatedLocation; + OriginalSpan = originalSourceSpan; + GeneratedSpan = generatedSourceSpan; } - public SourceSpan DocumentLocation { get; } + public SourceSpan OriginalSpan { get; } - public SourceSpan GeneratedLocation { get; } + public SourceSpan GeneratedSpan { get; } public override bool Equals(object obj) { var other = obj as LineMapping; + return Equals(other); + } + + public bool Equals(LineMapping other) + { if (ReferenceEquals(other, null)) { return false; } - return DocumentLocation.Equals(other.DocumentLocation) && - GeneratedLocation.Equals(other.GeneratedLocation); + return OriginalSpan.Equals(other.OriginalSpan) && + GeneratedSpan.Equals(other.GeneratedSpan); } public override int GetHashCode() { var hashCodeCombiner = HashCodeCombiner.Start(); - hashCodeCombiner.Add(DocumentLocation); - hashCodeCombiner.Add(GeneratedLocation); + hashCodeCombiner.Add(OriginalSpan); + hashCodeCombiner.Add(GeneratedSpan); return hashCodeCombiner; } @@ -73,7 +79,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy public override string ToString() { - return string.Format(CultureInfo.CurrentCulture, "{0} -> {1}", DocumentLocation, GeneratedLocation); + return string.Format(CultureInfo.CurrentCulture, "{0} -> {1}", OriginalSpan, GeneratedSpan); } } } diff --git a/src/Microsoft.AspNetCore.Razor.Evolution/RazorCSharpDocument.cs b/src/Microsoft.AspNetCore.Razor.Evolution/RazorCSharpDocument.cs index 3c5d162581..ab0b396337 100644 --- a/src/Microsoft.AspNetCore.Razor.Evolution/RazorCSharpDocument.cs +++ b/src/Microsoft.AspNetCore.Razor.Evolution/RazorCSharpDocument.cs @@ -10,7 +10,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution { public string GeneratedCode { get; set; } - internal IReadOnlyList LineMappings { get; set; } + public IReadOnlyList LineMappings { get; set; } public IReadOnlyList Diagnostics { get; set; } } diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/IntegrationTests/LineMappingsSerializer.cs b/test/Microsoft.AspNetCore.Razor.Evolution.Test/IntegrationTests/LineMappingsSerializer.cs index 38754fc75e..d5afa1647e 100644 --- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/IntegrationTests/LineMappingsSerializer.cs +++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/IntegrationTests/LineMappingsSerializer.cs @@ -20,10 +20,10 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests var lineMapping = csharpDocument.LineMappings[i]; builder.Append("Source Location: "); - AppendMappingLocation(builder, lineMapping.DocumentLocation, sourceContent); + AppendMappingLocation(builder, lineMapping.OriginalSpan, sourceContent); builder.Append("Generated Location: "); - AppendMappingLocation(builder, lineMapping.GeneratedLocation, csharpDocument.GeneratedCode); + AppendMappingLocation(builder, lineMapping.GeneratedSpan, csharpDocument.GeneratedCode); builder.AppendLine(); }