From d636d4de85899bb446c7b418b815cbdcaef39c40 Mon Sep 17 00:00:00 2001
From: Andrew Petrochuk <30735471+petrochuk@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:47:18 -0700
Subject: [PATCH] Added new source location class (#664)
---
src/Persistence/Models/SourceLocation.cs | 55 ++++++++++++++++++++++++
1 file changed, 55 insertions(+)
create mode 100644 src/Persistence/Models/SourceLocation.cs
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;
+ }
+}