diff --git a/src/Microsoft.AspNetCore.Razor.Language/SourceLocation.cs b/src/Microsoft.AspNetCore.Razor.Language/SourceLocation.cs index bb5ac8b973..de58f7c2aa 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/SourceLocation.cs +++ b/src/Microsoft.AspNetCore.Razor.Language/SourceLocation.cs @@ -116,9 +116,10 @@ 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; + AbsoluteIndex == other.AbsoluteIndex && + LineIndex == other.LineIndex && + CharacterIndex == other.CharacterIndex; } 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 e074835fd1..c1a8bea517 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 + 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, diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/SourceLocationTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/SourceLocationTest.cs index ec7fd726ca..c2401c56b7 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_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]