/
Diagnostic.cs
49 lines (39 loc) · 1.4 KB
/
Diagnostic.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) Microsoft and Contributors. All rights reserved. Licensed under the University of Illinois/NCSA Open Source License. See LICENSE.txt in the project root for license information.
using System;
using ClangSharp.Interop;
namespace ClangSharp
{
public sealed class Diagnostic : IEquatable<Diagnostic>
{
private readonly DiagnosticLevel _level;
private readonly string _message;
private readonly string _location;
public Diagnostic(DiagnosticLevel level, string message, CXSourceLocation location)
{
if (string.IsNullOrWhiteSpace(message))
{
throw new ArgumentNullException(nameof(message));
}
_level = level;
_message = message;
_location = location.ToString();
}
public DiagnosticLevel Level => _level;
public string Location => _location;
public string Message => _message;
public override bool Equals(object obj)
{
return (obj is Diagnostic other) && Equals(other);
}
public bool Equals(Diagnostic other)
{
return (_level == other.Level)
&& (_location == other.Location)
&& (_message == other.Message);
}
public override string ToString()
{
return $"{_level} ({_location}): {_message}";
}
}
}