From bace4a381808072f143f785fea165797d642e75c Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Tue, 19 Dec 2017 18:04:18 -0800 Subject: [PATCH] Revert "Include LineIndex and CharacterIndex when comparing SourceLocation" This reverts commit 0e20ea5178049d60656bc85472a381097be9c5bb. --- src/Microsoft.AspNetCore.Razor.Language/SourceLocation.cs | 5 ++--- .../Legacy/HtmlAttributeTest.cs | 4 ++-- .../SourceLocationTest.cs | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Language/SourceLocation.cs b/src/Microsoft.AspNetCore.Razor.Language/SourceLocation.cs index de58f7c2aa..bb5ac8b973 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/SourceLocation.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/SourceLocation.cs @@ -116,10 +116,9 @@ namespace Microsoft.AspNetCore.Razor.Language /// 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 && - LineIndex == other.LineIndex && - CharacterIndex == other.CharacterIndex; + AbsoluteIndex == other.AbsoluteIndex; } public static bool operator==(SourceLocation left, SourceLocation right) diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlAttributeTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlAttributeTest.cs index c1a8bea517..e074835fd1 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlAttributeTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/Legacy/HtmlAttributeTest.cs @@ -40,11 +40,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy var suffixLocation1 = new SourceLocation( absoluteIndex: 8 + newlineLength + attributeNameLength, lineIndex: 1, - characterIndex: 5); + characterIndex: 5 + attributeNameLength); var valueLocation1 = new SourceLocation( absoluteIndex: 5 + attributeNameLength + newlineLength, lineIndex: 1, - characterIndex: 2); + characterIndex: 2 + attributeNameLength); var prefixLocation2 = SourceLocationTracker.Advance(suffixLocation1, "'"); var suffixLocation2 = new SourceLocation( absoluteIndex: 15 + attributeNameLength * 2 + newlineLength * 2, diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/SourceLocationTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/SourceLocationTest.cs index c2401c56b7..ec7fd726ca 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/SourceLocationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Language.Test/SourceLocationTest.cs @@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Razor.Language } [Fact] - public void Equals_ReturnsFalse_FilePathsNullAndAbsoluteIndicesMatch() + public void Equals_ReturnsTrue_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.False(result); + Assert.True(result); } [Fact]