Expose `FilePath` on `MappingLocation`.
- We had the `FilePath` information available to us but we weren't exposing it on the `MappingLocation` context object. - By exposing the `FilePath` the Razor editor can 100% know where a `MappingLocation` is resolved from. If `null` the location is deemed to be the current source/generated file. #552
This commit is contained in:
parent
deaf2dc828
commit
be324b220a
|
|
@ -98,6 +98,7 @@ namespace Microsoft.AspNet.Razor.CodeGenerators
|
|||
{
|
||||
documentMapping = new MappingLocation(
|
||||
location: new SourceLocation(
|
||||
_documentMapping.FilePath,
|
||||
_documentMapping.AbsoluteIndex,
|
||||
_documentMapping.LineIndex,
|
||||
_documentMapping.CharacterIndex),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// 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;
|
||||
|
||||
|
|
@ -18,6 +19,7 @@ namespace Microsoft.AspNet.Razor.CodeGenerators
|
|||
AbsoluteIndex = location.AbsoluteIndex;
|
||||
LineIndex = location.LineIndex;
|
||||
CharacterIndex = location.CharacterIndex;
|
||||
FilePath = location.FilePath;
|
||||
}
|
||||
|
||||
public int ContentLength { get; }
|
||||
|
|
@ -28,6 +30,8 @@ namespace Microsoft.AspNet.Razor.CodeGenerators
|
|||
|
||||
public int CharacterIndex { get; }
|
||||
|
||||
public string FilePath { get; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var other = obj as MappingLocation;
|
||||
|
|
@ -36,7 +40,8 @@ namespace Microsoft.AspNet.Razor.CodeGenerators
|
|||
return false;
|
||||
}
|
||||
|
||||
return AbsoluteIndex == other.AbsoluteIndex &&
|
||||
return string.Equals(FilePath, other.FilePath, StringComparison.Ordinal) &&
|
||||
AbsoluteIndex == other.AbsoluteIndex &&
|
||||
ContentLength == other.ContentLength &&
|
||||
LineIndex == other.LineIndex &&
|
||||
CharacterIndex == other.CharacterIndex;
|
||||
|
|
@ -45,6 +50,7 @@ namespace Microsoft.AspNet.Razor.CodeGenerators
|
|||
public override int GetHashCode()
|
||||
{
|
||||
var hashCodeCombiner = HashCodeCombiner.Start();
|
||||
hashCodeCombiner.Add(FilePath, StringComparer.Ordinal);
|
||||
hashCodeCombiner.Add(AbsoluteIndex);
|
||||
hashCodeCombiner.Add(ContentLength);
|
||||
hashCodeCombiner.Add(LineIndex);
|
||||
|
|
@ -56,11 +62,12 @@ namespace Microsoft.AspNet.Razor.CodeGenerators
|
|||
public override string ToString()
|
||||
{
|
||||
return string.Format(
|
||||
CultureInfo.CurrentCulture, "({0}:{1},{2} [{3}])",
|
||||
CultureInfo.CurrentCulture, "({0}:{1},{2} [{3}] {4})",
|
||||
AbsoluteIndex,
|
||||
LineIndex,
|
||||
CharacterIndex,
|
||||
ContentLength);
|
||||
ContentLength,
|
||||
FilePath);
|
||||
}
|
||||
|
||||
public static bool operator ==(MappingLocation left, MappingLocation right)
|
||||
|
|
|
|||
Loading…
Reference in New Issue