зеркало из https://github.com/github/codeql.git
C#: Add sealed modifier to classes to fix dispose-pattern, remove explicit IDisposable implementations
This commit is contained in:
Родитель
397be7e98f
Коммит
e73ced2275
|
@ -12,7 +12,7 @@ namespace Semmle.Extraction.CIL
|
|||
/// Adds additional context that is specific for CIL extraction.
|
||||
/// One context = one DLL/EXE.
|
||||
/// </summary>
|
||||
partial class Context : IDisposable
|
||||
sealed partial class Context : IDisposable
|
||||
{
|
||||
readonly FileStream stream;
|
||||
Entities.Assembly? assemblyNull;
|
||||
|
@ -58,7 +58,7 @@ namespace Semmle.Extraction.CIL
|
|||
}
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
public void Dispose()
|
||||
{
|
||||
if (pdb != null)
|
||||
pdb.Dispose();
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace Semmle.Extraction.CIL
|
|||
/// <summary>
|
||||
/// Provides methods for creating and caching various entities.
|
||||
/// </summary>
|
||||
public partial class Context
|
||||
public sealed partial class Context
|
||||
{
|
||||
readonly Dictionary<object, Label> ids = new Dictionary<object, Label>();
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Semmle.Extraction.PDB
|
|||
///
|
||||
/// PDB information can be in a separate PDB file, or embedded in the DLL.
|
||||
/// </summary>
|
||||
class MetadataPdbReader : IPdb
|
||||
sealed class MetadataPdbReader : IPdb
|
||||
{
|
||||
class SourceFile : ISourceFile
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Semmle.Extraction.PDB
|
|||
/// A PDB reader using Microsoft.DiaSymReader.Native.
|
||||
/// This is an unmanaged Windows DLL, which therefore only works on Windows.
|
||||
/// </summary>
|
||||
class NativePdbReader : IPdb
|
||||
sealed class NativePdbReader : IPdb
|
||||
{
|
||||
sealed class Document : ISourceFile
|
||||
{
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace Semmle.BuildAnalyser
|
|||
/// <summary>
|
||||
/// Main implementation of the build analysis.
|
||||
/// </summary>
|
||||
class BuildAnalysis : IBuildAnalysis, IDisposable
|
||||
sealed class BuildAnalysis : IBuildAnalysis, IDisposable
|
||||
{
|
||||
private readonly AssemblyCache assemblyCache;
|
||||
private readonly IProgressMonitor progressMonitor;
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace Semmle.Extraction.CSharp.Standalone
|
|||
/// <summary>
|
||||
/// Searches for source/references and creates separate extractions.
|
||||
/// </summary>
|
||||
class Analysis : IDisposable
|
||||
sealed class Analysis : IDisposable
|
||||
{
|
||||
public Analysis(ILogger logger, Options options)
|
||||
{
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Semmle.Extraction.CSharp
|
|||
/// <summary>
|
||||
/// Encapsulates a C# analysis task.
|
||||
/// </summary>
|
||||
public class Analyser : IDisposable
|
||||
public sealed class Analyser : IDisposable
|
||||
{
|
||||
IExtractor extractor;
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ namespace Semmle.Extraction.Tests
|
|||
new Semmle.Extraction.Layout(null, null, "layout.txt"));
|
||||
}
|
||||
|
||||
class LoggerMock : ILogger
|
||||
sealed class LoggerMock : ILogger
|
||||
{
|
||||
public void Dispose() { }
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace Semmle.Extraction.Tests
|
|||
Assert.Equal(@"C:\Temp\source_archive\diskstation\share\source\def.cs", TrapWriter.NestPaths(logger, @"C:\Temp\source_archive", $@"{root3}{root3}diskstation\share\source\def.cs").Replace('/', '\\'));
|
||||
}
|
||||
|
||||
class LoggerMock : ILogger
|
||||
sealed class LoggerMock : ILogger
|
||||
{
|
||||
public void Dispose() { }
|
||||
|
||||
|
|
|
@ -283,7 +283,7 @@ namespace Semmle.Extraction
|
|||
|
||||
public IDisposable StackGuard => new ScopeGuard(this);
|
||||
|
||||
private class ScopeGuard : IDisposable
|
||||
private sealed class ScopeGuard : IDisposable
|
||||
{
|
||||
readonly Context cx;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ using System;
|
|||
|
||||
namespace SemmleTests.Semmle.Util
|
||||
{
|
||||
public class CanonicalPathCacheTest : IDisposable
|
||||
public sealed class CanonicalPathCacheTest : IDisposable
|
||||
{
|
||||
readonly ILogger Logger = new LoggerMock();
|
||||
readonly string root;
|
||||
|
@ -24,9 +24,10 @@ namespace SemmleTests.Semmle.Util
|
|||
root = Win32.IsWindows() ? @"X:\" : "/";
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
public void Dispose()
|
||||
{
|
||||
File.Delete("abc");
|
||||
Logger.Dispose();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -172,7 +173,7 @@ namespace SemmleTests.Semmle.Util
|
|||
CanonicalPathDots();
|
||||
}
|
||||
|
||||
class LoggerMock : ILogger
|
||||
sealed class LoggerMock : ILogger
|
||||
{
|
||||
public void Dispose() { }
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace SemmleTests.Semmle.Util
|
|||
/// Ensure that the Extractor works with long paths.
|
||||
/// These should be handled by .NET Core.
|
||||
/// </summary>
|
||||
public class LongPaths : IDisposable
|
||||
public sealed class LongPaths : IDisposable
|
||||
{
|
||||
static readonly string tmpDir = Path.GetTempPath();
|
||||
static readonly string shortPath = Path.Combine(tmpDir, "test.txt");
|
||||
|
@ -23,7 +23,7 @@ namespace SemmleTests.Semmle.Util
|
|||
CleanUp();
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
public void Dispose()
|
||||
{
|
||||
CleanUp();
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace Semmle.Util.Logging
|
|||
/// A logger that outputs to a <code>csharp.log</code>
|
||||
/// file.
|
||||
/// </summary>
|
||||
public class FileLogger : ILogger
|
||||
public sealed class FileLogger : ILogger
|
||||
{
|
||||
readonly StreamWriter writer;
|
||||
readonly Verbosity verbosity;
|
||||
|
@ -100,7 +100,7 @@ namespace Semmle.Util.Logging
|
|||
/// <summary>
|
||||
/// A logger that outputs to stdout/stderr.
|
||||
/// </summary>
|
||||
public class ConsoleLogger : ILogger
|
||||
public sealed class ConsoleLogger : ILogger
|
||||
{
|
||||
readonly Verbosity verbosity;
|
||||
|
||||
|
@ -143,7 +143,7 @@ namespace Semmle.Util.Logging
|
|||
/// <summary>
|
||||
/// A combined logger.
|
||||
/// </summary>
|
||||
public class CombinedLogger : ILogger
|
||||
public sealed class CombinedLogger : ILogger
|
||||
{
|
||||
readonly ILogger logger1;
|
||||
readonly ILogger logger2;
|
||||
|
|
Загрузка…
Ссылка в новой задаче