Fix IDisposable contract violation

This commit is contained in:
Michael B. Gale
2023-02-28 13:56:06 +00:00
parent be2d64a9d4
commit 6f3b5c01d5
2 changed files with 3 additions and 13 deletions

View File

@@ -240,7 +240,7 @@ namespace Semmle.Autobuild.Shared
SourceArchiveDir = RequireEnvironmentVariable(EnvVars.SourceArchiveDir(this.Options.Language));
DiagnosticsDir = RequireEnvironmentVariable(EnvVars.DiagnosticDir(this.Options.Language));
this.diagnostics = DiagnosticsStream.ForFile(Path.Combine(DiagnosticsDir, $"autobuilder-{DateTime.UtcNow:yyyyMMddHHmm}.jsonc"));
this.diagnostics = new DiagnosticsStream(Path.Combine(DiagnosticsDir, $"autobuilder-{DateTime.UtcNow:yyyyMMddHHmm}.jsonc"));
}
/// <summary>

View File

@@ -157,18 +157,10 @@ namespace Semmle.Util
/// Initialises a new <see cref="DiagnosticsStream" /> for a file at <paramref name="path" />.
/// </summary>
/// <param name="path">The path to the file that should be created.</param>
/// <returns>
/// A <see cref="DiagnosticsStream" /> object which allows diagnostics to be
/// written to a file at <paramname name="path" />.
/// </returns>
public static DiagnosticsStream ForFile(string path)
public DiagnosticsStream(string path)
{
var stream = File.CreateText(path);
return new DiagnosticsStream(stream);
}
this.writer = File.CreateText(path);
public DiagnosticsStream(StreamWriter streamWriter)
{
var contractResolver = new DefaultContractResolver
{
NamingStrategy = new CamelCaseNamingStrategy()
@@ -179,8 +171,6 @@ namespace Semmle.Util
ContractResolver = contractResolver,
NullValueHandling = NullValueHandling.Ignore
};
writer = streamWriter;
}
/// <summary>