diff --git a/csharp/extractor/Semmle.Extraction.CIL.Driver/Program.cs b/csharp/extractor/Semmle.Extraction.CIL.Driver/Program.cs
index 53542c970e9..940cd647ed8 100644
--- a/csharp/extractor/Semmle.Extraction.CIL.Driver/Program.cs
+++ b/csharp/extractor/Semmle.Extraction.CIL.Driver/Program.cs
@@ -24,7 +24,7 @@ namespace Semmle.Extraction.CIL.Driver
{
var sw = new Stopwatch();
sw.Start();
- Entities.Assembly.ExtractCIL(layout, assemblyPath, logger, nocache, extractPdbs, trapCompression, out _, out _);
+ Analyser.ExtractCIL(layout, assemblyPath, logger, nocache, extractPdbs, trapCompression, out _, out _);
sw.Stop();
logger.Log(Severity.Info, " {0} ({1})", assemblyPath, sw.Elapsed);
}
diff --git a/csharp/extractor/Semmle.Extraction.CIL/Analyser.cs b/csharp/extractor/Semmle.Extraction.CIL/Analyser.cs
new file mode 100644
index 00000000000..dee801cc171
--- /dev/null
+++ b/csharp/extractor/Semmle.Extraction.CIL/Analyser.cs
@@ -0,0 +1,53 @@
+using Semmle.Util.Logging;
+using System;
+using Semmle.Util;
+using Semmle.Extraction.CIL.Entities;
+
+namespace Semmle.Extraction.CIL
+{
+ public static class Analyser
+ {
+ private static void ExtractCIL(Extractor extractor, TrapWriter trapWriter, bool extractPdbs)
+ {
+ using var cilContext = new Context(extractor, trapWriter, extractor.OutputPath, extractPdbs);
+ cilContext.Populate(new Assembly(cilContext));
+ cilContext.PopulateAll();
+ }
+
+ ///
+ /// Main entry point to the CIL extractor.
+ /// Call this to extract a given assembly.
+ ///
+ /// The trap layout.
+ /// The full path of the assembly to extract.
+ /// The logger.
+ /// True to overwrite existing trap file.
+ /// Whether to extract PDBs.
+ /// The path of the trap file.
+ /// Whether the file was extracted (false=cached).
+ public static void ExtractCIL(Layout layout, string assemblyPath, ILogger logger, bool nocache, bool extractPdbs, TrapWriter.CompressionMode trapCompression, out string trapFile, out bool extracted)
+ {
+ trapFile = "";
+ extracted = false;
+ try
+ {
+ var canonicalPathCache = CanonicalPathCache.Create(logger, 1000);
+ var pathTransformer = new PathTransformer(canonicalPathCache);
+ var extractor = new Extractor(false, assemblyPath, logger, pathTransformer);
+ var transformedAssemblyPath = pathTransformer.Transform(assemblyPath);
+ var project = layout.LookupProjectOrDefault(transformedAssemblyPath);
+ using var trapWriter = project.CreateTrapWriter(logger, transformedAssemblyPath.WithSuffix(".cil"), trapCompression, discardDuplicates: true);
+ trapFile = trapWriter.TrapFile;
+ if (nocache || !System.IO.File.Exists(trapFile))
+ {
+ ExtractCIL(extractor, trapWriter, extractPdbs);
+ extracted = true;
+ }
+ }
+ catch (Exception ex) // lgtm[cs/catch-of-all-exceptions]
+ {
+ logger.Log(Severity.Error, string.Format("Exception extracting {0}: {1}", assemblyPath, ex));
+ }
+ }
+ }
+}
diff --git a/csharp/extractor/Semmle.Extraction.CIL/Context.Factories.cs b/csharp/extractor/Semmle.Extraction.CIL/Context.Factories.cs
index 1017b2f1a19..65c72487b65 100644
--- a/csharp/extractor/Semmle.Extraction.CIL/Context.Factories.cs
+++ b/csharp/extractor/Semmle.Extraction.CIL/Context.Factories.cs
@@ -9,11 +9,11 @@ namespace Semmle.Extraction.CIL
///
/// Provides methods for creating and caching various entities.
///
- public sealed partial class Context
+ internal sealed partial class Context
{
private readonly Dictionary