Make LineMapping public
This commit is contained in:
parent
3f5d1bb2d6
commit
adf18d4810
|
|
@ -1,40 +1,46 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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;
|
||||||
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 LineMapping
|
public sealed class LineMapping : IEquatable<LineMapping>
|
||||||
{
|
{
|
||||||
public LineMapping(SourceSpan documentLocation, SourceSpan generatedLocation)
|
public LineMapping(SourceSpan originalSourceSpan, SourceSpan generatedSourceSpan)
|
||||||
{
|
{
|
||||||
DocumentLocation = documentLocation;
|
OriginalSpan = originalSourceSpan;
|
||||||
GeneratedLocation = generatedLocation;
|
GeneratedSpan = generatedSourceSpan;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SourceSpan DocumentLocation { get; }
|
public SourceSpan OriginalSpan { get; }
|
||||||
|
|
||||||
public SourceSpan GeneratedLocation { get; }
|
public SourceSpan GeneratedSpan { get; }
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
var other = obj as LineMapping;
|
var other = obj as LineMapping;
|
||||||
|
return Equals(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Equals(LineMapping other)
|
||||||
|
{
|
||||||
if (ReferenceEquals(other, null))
|
if (ReferenceEquals(other, null))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DocumentLocation.Equals(other.DocumentLocation) &&
|
return OriginalSpan.Equals(other.OriginalSpan) &&
|
||||||
GeneratedLocation.Equals(other.GeneratedLocation);
|
GeneratedSpan.Equals(other.GeneratedSpan);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
var hashCodeCombiner = HashCodeCombiner.Start();
|
var hashCodeCombiner = HashCodeCombiner.Start();
|
||||||
hashCodeCombiner.Add(DocumentLocation);
|
hashCodeCombiner.Add(OriginalSpan);
|
||||||
hashCodeCombiner.Add(GeneratedLocation);
|
hashCodeCombiner.Add(GeneratedSpan);
|
||||||
|
|
||||||
return hashCodeCombiner;
|
return hashCodeCombiner;
|
||||||
}
|
}
|
||||||
|
|
@ -73,7 +79,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.Legacy
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return string.Format(CultureInfo.CurrentCulture, "{0} -> {1}", DocumentLocation, GeneratedLocation);
|
return string.Format(CultureInfo.CurrentCulture, "{0} -> {1}", OriginalSpan, GeneratedSpan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -10,7 +10,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution
|
||||||
{
|
{
|
||||||
public string GeneratedCode { get; set; }
|
public string GeneratedCode { get; set; }
|
||||||
|
|
||||||
internal IReadOnlyList<LineMapping> LineMappings { get; set; }
|
public IReadOnlyList<LineMapping> LineMappings { get; set; }
|
||||||
|
|
||||||
public IReadOnlyList<RazorError> Diagnostics { get; set; }
|
public IReadOnlyList<RazorError> Diagnostics { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,10 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests
|
||||||
var lineMapping = csharpDocument.LineMappings[i];
|
var lineMapping = csharpDocument.LineMappings[i];
|
||||||
|
|
||||||
builder.Append("Source Location: ");
|
builder.Append("Source Location: ");
|
||||||
AppendMappingLocation(builder, lineMapping.DocumentLocation, sourceContent);
|
AppendMappingLocation(builder, lineMapping.OriginalSpan, sourceContent);
|
||||||
|
|
||||||
builder.Append("Generated Location: ");
|
builder.Append("Generated Location: ");
|
||||||
AppendMappingLocation(builder, lineMapping.GeneratedLocation, csharpDocument.GeneratedCode);
|
AppendMappingLocation(builder, lineMapping.GeneratedSpan, csharpDocument.GeneratedCode);
|
||||||
|
|
||||||
builder.AppendLine();
|
builder.AppendLine();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue