Files
Discord.Net/test/Discord.Net.Analyzers.Tests/Helpers/DiagnosticResult.cs
NaN 257f246d1d Format the project with 'dotnet format' (#2551)
* Sync and Re-Format

* Fix Title string.

* Fix indentation.
2023-02-13 18:45:59 +01:00

88 lines
2.0 KiB
C#

using Microsoft.CodeAnalysis;
using System;
namespace TestHelper
{
/// <summary>
/// Location where the diagnostic appears, as determined by path, line number, and column number.
/// </summary>
public struct DiagnosticResultLocation
{
public DiagnosticResultLocation(string path, int line, int column)
{
if (line < -1)
{
throw new ArgumentOutOfRangeException(nameof(line), "line must be >= -1");
}
if (column < -1)
{
throw new ArgumentOutOfRangeException(nameof(column), "column must be >= -1");
}
Path = path;
Line = line;
Column = column;
}
public string Path { get; }
public int Line { get; }
public int Column { get; }
}
/// <summary>
/// Struct that stores information about a Diagnostic appearing in a source
/// </summary>
public struct DiagnosticResult
{
private DiagnosticResultLocation[] locations;
public DiagnosticResultLocation[] Locations
{
get
{
if (locations == null)
{
locations = new DiagnosticResultLocation[] { };
}
return locations;
}
set
{
locations = value;
}
}
public DiagnosticSeverity Severity { get; set; }
public string Id { get; set; }
public string Message { get; set; }
public string Path
{
get
{
return Locations.Length > 0 ? Locations[0].Path : "";
}
}
public int Line
{
get
{
return Locations.Length > 0 ? Locations[0].Line : -1;
}
}
public int Column
{
get
{
return Locations.Length > 0 ? Locations[0].Column : -1;
}
}
}
}