Struct SourcePosition
A position in a source document, expressed as a zero-based line number and a zero-based character offset.
public readonly record struct SourcePosition : IComparable<SourcePosition>, IEquatable<SourcePosition>
- Implements
- Inherited Members
- Extension Methods
Remarks
👉 Character offsets count UTF-16 code units, consistent with both the LSP default position encoding and the native encoding of VBA (BSTR) strings.
Constructors
SourcePosition(int, int)
A position in a source document, expressed as a zero-based line number and a zero-based character offset.
public SourcePosition(int Line, int Character)
Parameters
LineintThe zero-based line number.
CharacterintThe zero-based character (UTF-16 code unit) offset within the line.
Remarks
👉 Character offsets count UTF-16 code units, consistent with both the LSP default position encoding and the native encoding of VBA (BSTR) strings.
Properties
Character
The zero-based character (UTF-16 code unit) offset within the line.
public int Character { get; init; }
Property Value
Line
The zero-based line number.
public int Line { get; init; }
Property Value
Methods
CompareTo(SourcePosition)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
public int CompareTo(SourcePosition other)
Parameters
otherSourcePositionAn object to compare with this instance.
Returns
- int
A value that indicates the relative order of the objects being compared. The return value has these meanings:
Value Meaning Less than zero This instance precedes otherin the sort order.Zero This instance occurs in the same position in the sort order as other.Greater than zero This instance follows otherin the sort order.
Operators
operator >(SourcePosition, SourcePosition)
public static bool operator >(SourcePosition left, SourcePosition right)
Parameters
leftSourcePositionrightSourcePosition
Returns
operator >=(SourcePosition, SourcePosition)
public static bool operator >=(SourcePosition left, SourcePosition right)
Parameters
leftSourcePositionrightSourcePosition
Returns
operator <(SourcePosition, SourcePosition)
public static bool operator <(SourcePosition left, SourcePosition right)
Parameters
leftSourcePositionrightSourcePosition
Returns
operator <=(SourcePosition, SourcePosition)
public static bool operator <=(SourcePosition left, SourcePosition right)
Parameters
leftSourcePositionrightSourcePosition