AngleSharp by AngleSharp

<PackageReference Include="AngleSharp" Version="0.9.9.2" />

 TextPosition

The position in the source code.
using System; namespace AngleSharp { public struct TextPosition : IEquatable<TextPosition>, IComparable<TextPosition> { public static readonly TextPosition Empty; private readonly ushort _line; private readonly ushort _column; private readonly int _position; public int Line => _line; public int Column => _column; public int Position => _position; public TextPosition(ushort line, ushort column, int position) { _line = line; _column = column; _position = position; } public TextPosition Shift(int columns) { return new TextPosition(_line, (ushort)(_column + columns), _position + columns); } public TextPosition After(char chr) { ushort num = _line; ushort num2 = _column; if (chr == '\n') { num = (ushort)(num + 1); num2 = 0; } return new TextPosition(num, num2 = (ushort)(num2 + 1), _position + 1); } public TextPosition After(string str) { ushort num = _line; ushort num2 = _column; for (int i = 0; i < str.Length; i++) { if (str[i] == '\n') { num = (ushort)(num + 1); num2 = 0; } num2 = (ushort)(num2 + 1); } return new TextPosition(num, num2, _position + str.Length); } public override string ToString() { return string.Format("Ln {0}, Col {1}, Pos {2}", new object[3] { _line, _column, _position }); } public override int GetHashCode() { return _position ^ ((_line | _column) + _line); } public override bool Equals(object obj) { TextPosition? nullable = obj as TextPosition?; if (nullable.HasValue) return Equals(nullable.Value); return false; } public bool Equals(TextPosition other) { if (_position == other._position && _column == other._column) return _line == other._line; return false; } public static bool operator >(TextPosition a, TextPosition b) { return a._position > b._position; } public static bool operator <(TextPosition a, TextPosition b) { return a._position < b._position; } public int CompareTo(TextPosition other) { if (!Equals(other)) { if (!(this > other)) return -1; return 1; } return 0; } } }