mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
C#: Properly dispose diagnostic writer objects
This commit is contained in:
@@ -17,7 +17,7 @@ namespace Semmle.Autobuild.Cpp
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Console.WriteLine("CodeQL C++ autobuilder");
|
Console.WriteLine("CodeQL C++ autobuilder");
|
||||||
var builder = new CppAutobuilder(actions, options);
|
using var builder = new CppAutobuilder(actions, options);
|
||||||
return builder.AttemptBuild();
|
return builder.AttemptBuild();
|
||||||
}
|
}
|
||||||
catch (InvalidEnvironmentException ex)
|
catch (InvalidEnvironmentException ex)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace Semmle.Autobuild.CSharp
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Console.WriteLine("CodeQL C# autobuilder");
|
Console.WriteLine("CodeQL C# autobuilder");
|
||||||
var builder = new CSharpAutobuilder(actions, options);
|
using var builder = new CSharpAutobuilder(actions, options);
|
||||||
return builder.AttemptBuild();
|
return builder.AttemptBuild();
|
||||||
}
|
}
|
||||||
catch (InvalidEnvironmentException ex)
|
catch (InvalidEnvironmentException ex)
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ namespace Semmle.Autobuild.Shared
|
|||||||
/// The overall design is intended to be extensible so that in theory,
|
/// The overall design is intended to be extensible so that in theory,
|
||||||
/// it should be possible to add new build rules without touching this code.
|
/// it should be possible to add new build rules without touching this code.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class Autobuilder<TAutobuildOptions> : IAutobuilder<TAutobuildOptions> where TAutobuildOptions : AutobuildOptionsShared
|
public abstract class Autobuilder<TAutobuildOptions> : IDisposable, IAutobuilder<TAutobuildOptions> where TAutobuildOptions : AutobuildOptionsShared
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Full file paths of files found in the project directory, as well as
|
/// Full file paths of files found in the project directory, as well as
|
||||||
@@ -351,6 +351,20 @@ namespace Semmle.Autobuild.Shared
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose(true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing)
|
||||||
|
{
|
||||||
|
(diagnostics as IDisposable)?.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Value of CODEQL_EXTRACTOR_<LANG>_ROOT environment variable.
|
/// Value of CODEQL_EXTRACTOR_<LANG>_ROOT environment variable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user