Skip to content

Commit

Permalink
Added new source location class (#664)
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochuk authored Jun 6, 2024
1 parent c7bd171 commit d636d4d
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/Persistence/Models/SourceLocation.cs
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;
}
}

0 comments on commit d636d4d

Please sign in to comment.