Change SourceLocation to be serializable.
- Added comments to ensure users are aware of implications of using a set property on the SourceLocation class.
This commit is contained in:
parent
f53b6bb0e3
commit
565a31b200
|
|
@ -15,34 +15,24 @@ namespace Microsoft.AspNet.Razor.Text
|
||||||
public static readonly SourceLocation Undefined = CreateUndefined();
|
public static readonly SourceLocation Undefined = CreateUndefined();
|
||||||
public static readonly SourceLocation Zero = new SourceLocation(0, 0, 0);
|
public static readonly SourceLocation Zero = new SourceLocation(0, 0, 0);
|
||||||
|
|
||||||
private int _absoluteIndex;
|
|
||||||
private int _lineIndex;
|
|
||||||
private int _characterIndex;
|
|
||||||
|
|
||||||
public SourceLocation(int absoluteIndex, int lineIndex, int characterIndex)
|
public SourceLocation(int absoluteIndex, int lineIndex, int characterIndex)
|
||||||
{
|
{
|
||||||
_absoluteIndex = absoluteIndex;
|
AbsoluteIndex = absoluteIndex;
|
||||||
_lineIndex = lineIndex;
|
LineIndex = lineIndex;
|
||||||
_characterIndex = characterIndex;
|
CharacterIndex = characterIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int AbsoluteIndex
|
/// <remarks>Set property is only accessible for deserialization purposes.</remarks>
|
||||||
{
|
public int AbsoluteIndex { get; set; }
|
||||||
get { return _absoluteIndex; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the 1-based index of the line referred to by this Source Location.
|
/// Gets the 1-based index of the line referred to by this Source Location.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int LineIndex
|
/// <remarks>Set property is only accessible for deserialization purposes.</remarks>
|
||||||
{
|
public int LineIndex { get; set; }
|
||||||
get { return _lineIndex; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public int CharacterIndex
|
/// <remarks>Set property is only accessible for deserialization purposes.</remarks>
|
||||||
{
|
public int CharacterIndex { get; set; }
|
||||||
get { return _characterIndex; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
|
|
@ -102,9 +92,9 @@ namespace Microsoft.AspNet.Razor.Text
|
||||||
private static SourceLocation CreateUndefined()
|
private static SourceLocation CreateUndefined()
|
||||||
{
|
{
|
||||||
var sl = new SourceLocation();
|
var sl = new SourceLocation();
|
||||||
sl._absoluteIndex = -1;
|
sl.AbsoluteIndex = -1;
|
||||||
sl._lineIndex = -1;
|
sl.LineIndex = -1;
|
||||||
sl._characterIndex = -1;
|
sl.CharacterIndex = -1;
|
||||||
return sl;
|
return sl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue