diff --git a/src/Persistence/Models/SourceLocation.cs b/src/Persistence/Models/SourceLocation.cs new file mode 100644 index 00000000..11caf43c --- /dev/null +++ b/src/Persistence/Models/SourceLocation.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +namespace Microsoft.PowerPlatform.PowerApps.Persistence.Models; + +/// +/// Source location +/// +[DebuggerDisplay("l:{Line}, c:{Column}, f:{FilePath}")] +public record SourceLocation +{ + /// + /// File path + /// + public string? FilePath { get; init; } + public int? Line { get; init; } + public int? Column { get; init; } + + /// + /// Default constructor + /// + public SourceLocation() + { + } + + /// + /// Parameterized constructor + /// + /// + /// + /// + public SourceLocation(string? filePath, int? line, int? column) + { + FilePath = filePath; + + if (line != null && line < 0) + throw new ArgumentOutOfRangeException(nameof(line)); + Line = line; + + if (column != null && column < 0) + throw new ArgumentOutOfRangeException(nameof(column)); + Column = column; + } + + /// + /// Copy constructor + /// + /// + public SourceLocation(SourceLocation sourceLocation) + { + FilePath = sourceLocation.FilePath; + Line = sourceLocation.Line; + Column = sourceLocation.Column; + } +}