Last change
on this file since 14933 was
14933,
checked in by gkronber, 7 years ago
|
#2520 added a code fix for generating StorableTypeAttributes
|
File size:
1.7 KB
|
Line | |
---|
1 | using Microsoft.CodeAnalysis;
|
---|
2 | using System;
|
---|
3 |
|
---|
4 | namespace TestHelper {
|
---|
5 | /// <summary>
|
---|
6 | /// Location where the diagnostic appears, as determined by path, line number, and column number.
|
---|
7 | /// </summary>
|
---|
8 | public struct DiagnosticResultLocation {
|
---|
9 | public DiagnosticResultLocation(string path, int line, int column) {
|
---|
10 | if (line < -1) {
|
---|
11 | throw new ArgumentOutOfRangeException(nameof(line), "line must be >= -1");
|
---|
12 | }
|
---|
13 |
|
---|
14 | if (column < -1) {
|
---|
15 | throw new ArgumentOutOfRangeException(nameof(column), "column must be >= -1");
|
---|
16 | }
|
---|
17 |
|
---|
18 | this.Path = path;
|
---|
19 | this.Line = line;
|
---|
20 | this.Column = column;
|
---|
21 | }
|
---|
22 |
|
---|
23 | public string Path { get; }
|
---|
24 | public int Line { get; }
|
---|
25 | public int Column { get; }
|
---|
26 | }
|
---|
27 |
|
---|
28 | /// <summary>
|
---|
29 | /// Struct that stores information about a Diagnostic appearing in a source
|
---|
30 | /// </summary>
|
---|
31 | public struct DiagnosticResult {
|
---|
32 | private DiagnosticResultLocation[] locations;
|
---|
33 |
|
---|
34 | public DiagnosticResultLocation[] Locations {
|
---|
35 | get {
|
---|
36 | if (this.locations == null) {
|
---|
37 | this.locations = new DiagnosticResultLocation[] { };
|
---|
38 | }
|
---|
39 | return this.locations;
|
---|
40 | }
|
---|
41 |
|
---|
42 | set {
|
---|
43 | this.locations = value;
|
---|
44 | }
|
---|
45 | }
|
---|
46 |
|
---|
47 | public DiagnosticSeverity Severity { get; set; }
|
---|
48 |
|
---|
49 | public string Id { get; set; }
|
---|
50 |
|
---|
51 | public string Message { get; set; }
|
---|
52 |
|
---|
53 | public string Path {
|
---|
54 | get {
|
---|
55 | return this.Locations.Length > 0 ? this.Locations[0].Path : "";
|
---|
56 | }
|
---|
57 | }
|
---|
58 |
|
---|
59 | public int Line {
|
---|
60 | get {
|
---|
61 | return this.Locations.Length > 0 ? this.Locations[0].Line : -1;
|
---|
62 | }
|
---|
63 | }
|
---|
64 |
|
---|
65 | public int Column {
|
---|
66 | get {
|
---|
67 | return this.Locations.Length > 0 ? this.Locations[0].Column : -1;
|
---|
68 | }
|
---|
69 | }
|
---|
70 | }
|
---|
71 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.