Struct SourceRange
A contiguous span in a source document, from a Start position (inclusive) to an End position (exclusive).
public readonly record struct SourceRange : IComparable<SourceRange>, IEquatable<SourceRange>
- Implements
- Inherited Members
- Extension Methods
Remarks
IComparable compares source location start.
Constructors
SourceRange(SourcePosition, SourcePosition)
A contiguous span in a source document, from a Start position (inclusive) to an End position (exclusive).
public SourceRange(SourcePosition Start, SourcePosition End)
Parameters
StartSourcePositionThe inclusive start position of the range.
EndSourcePositionThe exclusive end position of the range.
Remarks
IComparable compares source location start.
SourceRange(int, int, int, int)
Creates a SourceRange from zero-based start/end line numbers and character offsets.
public SourceRange(int startLine, int startCharacter, int endLine, int endCharacter)
Parameters
Properties
Empty
Gets an empty range at position L0C0.
public static SourceRange Empty { get; }
Property Value
End
The exclusive end position of the range.
public SourcePosition End { get; init; }
Property Value
IsEmpty
true if this range spans no characters (Start and End are the same position).
public bool IsEmpty { get; }
Property Value
Start
The inclusive start position of the range.
public SourcePosition Start { get; init; }
Property Value
Methods
CompareTo(SourceRange)
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(SourceRange other)
Parameters
otherSourceRangeAn 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.