-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new source location class (#664)
- Loading branch information
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
namespace Microsoft.PowerPlatform.PowerApps.Persistence.Models; | ||
|
||
/// <summary> | ||
/// Source location | ||
/// </summary> | ||
[DebuggerDisplay("l:{Line}, c:{Column}, f:{FilePath}")] | ||
public record SourceLocation | ||
{ | ||
/// <summary> | ||
/// File path | ||
/// </summary> | ||
public string? FilePath { get; init; } | ||
public int? Line { get; init; } | ||
public int? Column { get; init; } | ||
|
||
/// <summary> | ||
/// Default constructor | ||
/// </summary> | ||
public SourceLocation() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Parameterized constructor | ||
/// </summary> | ||
/// <param name="filePath"></param> | ||
/// <param name="line"></param> | ||
/// <param name="column"></param> | ||
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; | ||
} | ||
|
||
/// <summary> | ||
/// Copy constructor | ||
/// </summary> | ||
/// <param name="sourceLocation"></param> | ||
public SourceLocation(SourceLocation sourceLocation) | ||
{ | ||
FilePath = sourceLocation.FilePath; | ||
Line = sourceLocation.Line; | ||
Column = sourceLocation.Column; | ||
} | ||
} |