Revert "Revert "Include LineIndex and CharacterIndex when comparing SourceLocation""

This reverts commit bace4a3818.
This commit is contained in:
Ajay Bhargav Baaskaran 2017-12-20 15:25:10 -08:00
parent 82a68d73de
commit d419566534
3 changed files with 8 additions and 7 deletions

View File

@ -116,9 +116,10 @@ namespace Microsoft.AspNetCore.Razor.Language
/// <inheritdoc />
public bool Equals(SourceLocation other)
{
// LineIndex and CharacterIndex can be calculated from AbsoluteIndex and the document content.
return string.Equals(FilePath, other.FilePath, StringComparison.Ordinal) &&
AbsoluteIndex == other.AbsoluteIndex;
AbsoluteIndex == other.AbsoluteIndex &&
LineIndex == other.LineIndex &&
CharacterIndex == other.CharacterIndex;
}
public static bool operator==(SourceLocation left, SourceLocation right)

View File

@ -40,11 +40,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
var suffixLocation1 = new SourceLocation(
absoluteIndex: 8 + newlineLength + attributeNameLength,
lineIndex: 1,
characterIndex: 5 + attributeNameLength);
characterIndex: 5);
var valueLocation1 = new SourceLocation(
absoluteIndex: 5 + attributeNameLength + newlineLength,
lineIndex: 1,
characterIndex: 2 + attributeNameLength);
characterIndex: 2);
var prefixLocation2 = SourceLocationTracker.Advance(suffixLocation1, "'");
var suffixLocation2 = new SourceLocation(
absoluteIndex: 15 + attributeNameLength * 2 + newlineLength * 2,
@ -102,7 +102,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
var suffixLocation1 = new SourceLocation(
absoluteIndex: 10 + newlineLength + attributeNameLength,
lineIndex: 1,
characterIndex: 5 + attributeNameLength + newlineLength);
characterIndex: 7 + attributeNameLength);
var valueLocation1 = new SourceLocation(
absoluteIndex: 7 + attributeNameLength + newlineLength,
lineIndex: 1,

View File

@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Razor.Language
}
[Fact]
public void Equals_ReturnsTrue_FilePathsNullAndAbsoluteIndicesMatch()
public void Equals_ReturnsFalse_FilePathsNullAndAbsoluteIndicesMatch()
{
// Arrange
var sourceLocationA = new SourceLocation(10, 3, 4);
@ -71,7 +71,7 @@ namespace Microsoft.AspNetCore.Razor.Language
var result = sourceLocationA.Equals(sourceLocationB);
// Assert
Assert.True(result);
Assert.False(result);
}
[Fact]