Skip to content

Commit fbec197

Browse files
committed
Move TSP diagnostics related classes to separate files
1 parent 305fa84 commit fbec197

File tree

3 files changed

+71
-61
lines changed

3 files changed

+71
-61
lines changed

csharp/extractor/Semmle.Util/ToolStatusPage.cs renamed to csharp/extractor/Semmle.Util/ToolStatusPage/DiagnosticMessage.cs

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Globalization;
4-
using System.IO;
54
using Newtonsoft.Json;
65
using Newtonsoft.Json.Converters;
76
using Newtonsoft.Json.Serialization;
@@ -179,64 +178,4 @@ public DiagnosticMessage(
179178
this.PlaintextMessage = plaintextMessage;
180179
}
181180
}
182-
183-
/// <summary>
184-
/// Provides the ability to write diagnostic messages to some output.
185-
/// </summary>
186-
public interface IDiagnosticsWriter : IDisposable
187-
{
188-
/// <summary>
189-
/// Adds <paramref name="message" /> as a new diagnostics entry.
190-
/// </summary>
191-
/// <param name="message">The diagnostics entry to add.</param>
192-
void AddEntry(DiagnosticMessage message);
193-
}
194-
195-
/// <summary>
196-
/// A wrapper around an underlying <see cref="StreamWriter" /> which allows
197-
/// <see cref="DiagnosticMessage" /> objects to be serialized to it.
198-
/// </summary>
199-
public sealed class DiagnosticsStream : IDiagnosticsWriter, IDisposable
200-
{
201-
private readonly JsonSerializer serializer;
202-
private readonly StreamWriter writer;
203-
204-
/// <summary>
205-
/// Initialises a new <see cref="DiagnosticsStream" /> for a file at <paramref name="path" />.
206-
/// </summary>
207-
/// <param name="path">The path to the file that should be created.</param>
208-
public DiagnosticsStream(string path)
209-
{
210-
this.writer = File.CreateText(path);
211-
212-
var contractResolver = new DefaultContractResolver
213-
{
214-
NamingStrategy = new CamelCaseNamingStrategy()
215-
};
216-
217-
serializer = new JsonSerializer
218-
{
219-
ContractResolver = contractResolver,
220-
NullValueHandling = NullValueHandling.Ignore
221-
};
222-
}
223-
224-
/// <summary>
225-
/// Adds <paramref name="message" /> as a new diagnostics entry.
226-
/// </summary>
227-
/// <param name="message">The diagnostics entry to add.</param>
228-
public void AddEntry(DiagnosticMessage message)
229-
{
230-
serializer.Serialize(writer, message);
231-
writer.Flush();
232-
}
233-
234-
/// <summary>
235-
/// Releases all resources used by the <see cref="DiagnosticsStream" /> object.
236-
/// </summary>
237-
public void Dispose()
238-
{
239-
writer.Dispose();
240-
}
241-
}
242181
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System;
2+
using System.IO;
3+
using Newtonsoft.Json;
4+
using Newtonsoft.Json.Serialization;
5+
6+
namespace Semmle.Util
7+
{
8+
/// <summary>
9+
/// A wrapper around an underlying <see cref="StreamWriter" /> which allows
10+
/// <see cref="DiagnosticMessage" /> objects to be serialized to it.
11+
/// </summary>
12+
public sealed class DiagnosticsStream : IDiagnosticsWriter, IDisposable
13+
{
14+
private readonly JsonSerializer serializer;
15+
private readonly StreamWriter writer;
16+
17+
/// <summary>
18+
/// Initialises a new <see cref="DiagnosticsStream" /> for a file at <paramref name="path" />.
19+
/// </summary>
20+
/// <param name="path">The path to the file that should be created.</param>
21+
public DiagnosticsStream(string path)
22+
{
23+
this.writer = File.CreateText(path);
24+
25+
var contractResolver = new DefaultContractResolver
26+
{
27+
NamingStrategy = new CamelCaseNamingStrategy()
28+
};
29+
30+
serializer = new JsonSerializer
31+
{
32+
ContractResolver = contractResolver,
33+
NullValueHandling = NullValueHandling.Ignore
34+
};
35+
}
36+
37+
/// <summary>
38+
/// Adds <paramref name="message" /> as a new diagnostics entry.
39+
/// </summary>
40+
/// <param name="message">The diagnostics entry to add.</param>
41+
public void AddEntry(DiagnosticMessage message)
42+
{
43+
serializer.Serialize(writer, message);
44+
writer.Flush();
45+
}
46+
47+
/// <summary>
48+
/// Releases all resources used by the <see cref="DiagnosticsStream" /> object.
49+
/// </summary>
50+
public void Dispose()
51+
{
52+
writer.Dispose();
53+
}
54+
}
55+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
3+
namespace Semmle.Util
4+
{
5+
/// <summary>
6+
/// Provides the ability to write diagnostic messages to some output.
7+
/// </summary>
8+
public interface IDiagnosticsWriter : IDisposable
9+
{
10+
/// <summary>
11+
/// Adds <paramref name="message" /> as a new diagnostics entry.
12+
/// </summary>
13+
/// <param name="message">The diagnostics entry to add.</param>
14+
void AddEntry(DiagnosticMessage message);
15+
}
16+
}

0 commit comments

Comments
 (0)