File tree Expand file tree Collapse file tree 6 files changed +23
-5
lines changed
Semmle.Autobuild.Cpp.Tests
Semmle.Autobuild.CSharp.Tests Expand file tree Collapse file tree 6 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -203,6 +203,8 @@ internal class TestDiagnosticWriter : IDiagnosticsWriter
203
203
public IList < DiagnosticMessage > Diagnostics { get ; } = new List < DiagnosticMessage > ( ) ;
204
204
205
205
public void AddEntry ( DiagnosticMessage message ) => this . Diagnostics . Add ( message ) ;
206
+
207
+ public void Dispose ( ) { }
206
208
}
207
209
208
210
/// <summary>
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ static int Main()
17
17
try
18
18
{
19
19
Console . WriteLine ( "CodeQL C++ autobuilder" ) ;
20
- var builder = new CppAutobuilder ( actions , options ) ;
20
+ using var builder = new CppAutobuilder ( actions , options ) ;
21
21
return builder . AttemptBuild ( ) ;
22
22
}
23
23
catch ( InvalidEnvironmentException ex )
Original file line number Diff line number Diff line change @@ -218,6 +218,8 @@ internal class TestDiagnosticWriter : IDiagnosticsWriter
218
218
public IList < DiagnosticMessage > Diagnostics { get ; } = new List < DiagnosticMessage > ( ) ;
219
219
220
220
public void AddEntry ( DiagnosticMessage message ) => this . Diagnostics . Add ( message ) ;
221
+
222
+ public void Dispose ( ) { }
221
223
}
222
224
223
225
/// <summary>
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ public static int Main()
17
17
try
18
18
{
19
19
Console . WriteLine ( "CodeQL C# autobuilder" ) ;
20
- var builder = new CSharpAutobuilder ( actions , options ) ;
20
+ using var builder = new CSharpAutobuilder ( actions , options ) ;
21
21
return builder . AttemptBuild ( ) ;
22
22
}
23
23
catch ( InvalidEnvironmentException ex )
Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ public interface IAutobuilder<out TAutobuildOptions> where TAutobuildOptions : A
92
92
/// The overall design is intended to be extensible so that in theory,
93
93
/// it should be possible to add new build rules without touching this code.
94
94
/// </summary>
95
- public abstract class Autobuilder < TAutobuildOptions > : IAutobuilder < TAutobuildOptions > where TAutobuildOptions : AutobuildOptionsShared
95
+ public abstract class Autobuilder < TAutobuildOptions > : IDisposable , IAutobuilder < TAutobuildOptions > where TAutobuildOptions : AutobuildOptionsShared
96
96
{
97
97
/// <summary>
98
98
/// Full file paths of files found in the project directory, as well as
@@ -370,6 +370,20 @@ protected BuildScript AutobuildFailure() =>
370
370
}
371
371
} ) ;
372
372
373
+ public void Dispose ( )
374
+ {
375
+ Dispose ( true ) ;
376
+ GC . SuppressFinalize ( this ) ;
377
+ }
378
+
379
+ protected virtual void Dispose ( bool disposing )
380
+ {
381
+ if ( disposing )
382
+ {
383
+ diagnostics ? . Dispose ( ) ;
384
+ }
385
+ }
386
+
373
387
/// <summary>
374
388
/// Value of CODEQL_EXTRACTOR_<LANG>_ROOT environment variable.
375
389
/// </summary>
Original file line number Diff line number Diff line change @@ -182,7 +182,7 @@ public DiagnosticMessage(
182
182
/// <summary>
183
183
/// Provides the ability to write diagnostic messages to some output.
184
184
/// </summary>
185
- public interface IDiagnosticsWriter
185
+ public interface IDiagnosticsWriter : IDisposable
186
186
{
187
187
/// <summary>
188
188
/// Adds <paramref name="message" /> as a new diagnostics entry.
@@ -195,7 +195,7 @@ public interface IDiagnosticsWriter
195
195
/// A wrapper around an underlying <see cref="StreamWriter" /> which allows
196
196
/// <see cref="DiagnosticMessage" /> objects to be serialized to it.
197
197
/// </summary>
198
- public sealed class DiagnosticsStream : IDiagnosticsWriter , IDisposable
198
+ public sealed class DiagnosticsStream : IDiagnosticsWriter
199
199
{
200
200
private readonly JsonSerializer serializer ;
201
201
private readonly StreamWriter writer ;
You can’t perform that action at this time.
0 commit comments