Skip to content

Commit 2697677

Browse files
committed
Merge Extractor.Standalone and OutputPath
1 parent 10ab17a commit 2697677

File tree

7 files changed

+11
-20
lines changed

7 files changed

+11
-20
lines changed

csharp/extractor/Semmle.Extraction.CIL/Analyser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static void ExtractCIL(Layout layout, string assemblyPath, ILogger logger
3333
{
3434
var canonicalPathCache = CanonicalPathCache.Create(logger, 1000);
3535
var pathTransformer = new PathTransformer(canonicalPathCache);
36-
var extractor = new Extractor(false, assemblyPath, logger, pathTransformer);
36+
var extractor = new Extractor(assemblyPath, logger, pathTransformer);
3737
var transformedAssemblyPath = pathTransformer.Transform(assemblyPath);
3838
var project = layout.LookupProjectOrDefault(transformedAssemblyPath);
3939
using var trapWriter = project.CreateTrapWriter(logger, transformedAssemblyPath.WithSuffix(".cil"), trapCompression, discardDuplicates: true);

csharp/extractor/Semmle.Extraction.CSharp/Analyser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void EndInitialize(
7676
layout = new Layout();
7777
this.options = options;
7878
this.compilation = compilation;
79-
extractor = new Extraction.Extractor(false, GetOutputName(compilation, commandLineArguments), Logger, PathTransformer);
79+
extractor = new Extraction.Extractor(GetOutputName(compilation, commandLineArguments), Logger, PathTransformer);
8080
LogDiagnostics();
8181

8282
SetReferencePaths();
@@ -126,7 +126,7 @@ public void InitializeStandalone(CSharpCompilation compilationIn, CommonOptions
126126
{
127127
compilation = compilationIn;
128128
layout = new Layout();
129-
extractor = new Extraction.Extractor(true, null, Logger, PathTransformer);
129+
extractor = new Extraction.Extractor(null, Logger, PathTransformer);
130130
this.options = options;
131131
LogExtractorInfo(Extraction.Extractor.Version);
132132
SetReferencePaths();

csharp/extractor/Semmle.Extraction.CSharp/Entities/Assembly.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ private class AssemblyConstructorFactory : CachedEntityFactory<Microsoft.CodeAna
6565

6666
public static Assembly CreateOutputAssembly(Context cx)
6767
{
68-
if (cx.Extractor.OutputPath == null)
68+
if (cx.Extractor.Standalone)
6969
throw new InternalError("Attempting to create the output assembly in standalone extraction mode");
7070
return AssemblyConstructorFactory.Instance.CreateEntity(cx, outputAssemblyCacheKey, null);
7171
}

csharp/extractor/Semmle.Extraction.CSharp/Entities/Attribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public override void Populate(TextWriter trapFile)
5353

5454
if (attributeSyntax is object)
5555
{
56-
if (Context.Extractor.OutputPath != null)
56+
if (!Context.Extractor.Standalone)
5757
{
5858
trapFile.attribute_location(this, Assembly.CreateOutputAssembly(Context));
5959
}

csharp/extractor/Semmle.Extraction.CSharp/Entities/CachedSymbol.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public virtual IEnumerable<Extraction.Entities.Location> Locations
8383
{
8484
// Some built in operators lack locations, so loc is null.
8585
yield return Context.CreateLocation(ReportingLocation);
86-
if (Context.Extractor.OutputPath != null && loc.Kind == LocationKind.SourceFile)
86+
if (!Context.Extractor.Standalone && loc.Kind == LocationKind.SourceFile)
8787
yield return Assembly.CreateOutputAssembly(Context);
8888
}
8989
}

csharp/extractor/Semmle.Extraction.CSharp/Entities/Types/NamedType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public override IEnumerable<Extraction.Entities.Location> Locations
108108
foreach (var l in GetLocations(Symbol))
109109
yield return Context.CreateLocation(l);
110110

111-
if (Context.Extractor.OutputPath != null && Symbol.DeclaringSyntaxReferences.Any())
111+
if (!Context.Extractor.Standalone && Symbol.DeclaringSyntaxReferences.Any())
112112
yield return Assembly.CreateOutputAssembly(Context);
113113
}
114114
}

csharp/extractor/Semmle.Extraction/Extractor.cs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,18 @@ namespace Semmle.Extraction
99
/// </summary>
1010
public class Extractor
1111
{
12-
public bool Standalone
13-
{
14-
get; private set;
15-
}
12+
public bool Standalone => OutputPath is null;
13+
14+
public string OutputPath { get; }
1615

1716
/// <summary>
1817
/// Creates a new extractor instance for one compilation unit.
1918
/// </summary>
20-
/// <param name="standalone">If the extraction is standalone.</param>
2119
/// <param name="outputPath">The name of the output DLL/EXE, or null if not specified (standalone extraction).</param>
2220
/// <param name="logger">The object used for logging.</param>
2321
/// <param name="pathTransformer">The object used for path transformations.</param>
24-
public Extractor(bool standalone, string outputPath, ILogger logger, PathTransformer pathTransformer)
22+
public Extractor(string outputPath, ILogger logger, PathTransformer pathTransformer)
2523
{
26-
Standalone = standalone;
2724
OutputPath = outputPath;
2825
Logger = logger;
2926
PathTransformer = pathTransformer;
@@ -102,12 +99,6 @@ public void MissingNamespace(string fqdn, bool fromSource)
10299

103100
public IEnumerable<string> MissingNamespaces => missingNamespaces;
104101

105-
public string OutputPath
106-
{
107-
get;
108-
private set;
109-
}
110-
111102
public ILogger Logger { get; private set; }
112103

113104
public static string Version => $"{ThisAssembly.Git.BaseTag} ({ThisAssembly.Git.Sha})";

0 commit comments

Comments
 (0)