Location Class
Represents where something was found in source: a character range and, when it is known, the text that range indexes into.
public sealed class Location : IEquatable<Location>Example
var text = "one\ntwo\nthree line here";
var location = new Location(new TextSpan(15, 7), SourceText.From(text));
// Lines and columns are zero-based
Assert.Equal("(2,7)-(2,14)", location.ToString());
Assert.Equal(2, location.GetLineSpan().Start.Line);- Implements
Constructors
| Name | Description |
|---|---|
| Location(TextSpan, SourceText?) |
Location(TextSpan, SourceText?)
Location.cspublic Location(TextSpan sourceSpan, SourceText? sourceText = null)Parameters
sourceSpanTextSpansourceTextSourceText?
No documentation is available.
Properties
| Name | Description |
|---|---|
| None | A location that points at no text. |
| SourceSpan | The character range this location covers. |
| SourceText | The text Location.SourceSpan indexes into, or null when the location is not bound to any text. |
None
Location.csSourceSpan
Location.csSourceText
Location.csThe text Location.SourceSpan indexes into, or null when the location is not bound to any text.
public SourceText? SourceText { get; }Property value
Methods
| Name | Description |
|---|---|
| Equals(Location?) | Compares the span by value and the source text by reference, so two locations are equal only when they point at the same range of the same text. |
| Equals(object?) | |
| GetHashCode() | |
| GetLineSpan() | Maps Location.SourceSpan onto line and character positions. Returns default when Location.SourceText is null. |
| ToString() | Returns the line span, or the character range when the location is not bound to any text. |
GetHashCode()
Location.csGetLineSpan()
Location.csMaps Location.SourceSpan onto line and character positions. Returns default when Location.SourceText is null.
public LinePositionSpan GetLineSpan()