using System.Text; namespace XNeedle { /// /// Carries the origin information for a loaded XML document: /// the file path, the detected encoding, and the line number of the /// associated node (-1 when line information is unavailable). /// public struct SourceLocation { public string FilePath { get; set; } public Encoding Encoding { get; set; } /// /// 1-based line number of the associated node, or -1 if unknown. /// public int LineNumber { get; set; } public SourceLocation(string filePath, Encoding encoding, int lineNumber = -1) { FilePath = filePath; Encoding = encoding; LineNumber = lineNumber; } public SourceLocation WithLineNumber(int lineNumber) => new SourceLocation(FilePath, Encoding, lineNumber); public SourceLocation AsSynthetic() => new SourceLocation("", Encoding, -1); } }