Skip to content

Commit c2b835d

Browse files
committed
C#: Re-factor the check whether we are in standalone mode.
1 parent 9af170f commit c2b835d

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public override void Populate(TextWriter trapFile)
3131
{
3232
if (assemblyPath is not null)
3333
{
34-
var isBuildlessOutputAssembly = isOutputAssembly && Context.ExtractionContext.Mode.HasFlag(ExtractorMode.Standalone);
34+
var isBuildlessOutputAssembly = isOutputAssembly && Context.ExtractionContext.IsStandalone;
3535
var identifier = isBuildlessOutputAssembly
3636
? ""
3737
: assembly.ToString() ?? "";
@@ -72,7 +72,7 @@ public static Assembly CreateOutputAssembly(Context cx)
7272

7373
public override void WriteId(EscapingTextWriter trapFile)
7474
{
75-
if (isOutputAssembly && Context.ExtractionContext.Mode.HasFlag(ExtractorMode.Standalone))
75+
if (isOutputAssembly && Context.ExtractionContext.IsStandalone)
7676
{
7777
trapFile.Write("buildlessOutputAssembly");
7878
}

csharp/extractor/Semmle.Extraction.CSharp/Entities/Expressions/Invocation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public IMethodSymbol? TargetSymbol
133133
.Where(method => method.Parameters.Length >= Syntax.ArgumentList.Arguments.Count)
134134
.Where(method => method.Parameters.Count(p => !p.HasExplicitDefaultValue) <= Syntax.ArgumentList.Arguments.Count);
135135

136-
return Context.ExtractionContext.Mode.HasFlag(ExtractorMode.Standalone) ?
136+
return Context.ExtractionContext.IsStandalone ?
137137
candidates.FirstOrDefault() :
138138
candidates.SingleOrDefault();
139139
}

csharp/extractor/Semmle.Extraction.CSharp/Extractor/Context.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ private void ExtractionError(InternalError error)
376376

377377
private void ReportError(InternalError error)
378378
{
379-
if (!ExtractionContext.Mode.HasFlag(ExtractorMode.Standalone))
379+
if (!ExtractionContext.IsStandalone)
380380
throw error;
381381

382382
ExtractionError(error);

csharp/extractor/Semmle.Extraction.CSharp/Extractor/ExtractionContext.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class ExtractionContext
1515
public ExtractorMode Mode { get; }
1616
public string OutputPath { get; }
1717
public IEnumerable<CompilationInfo> CompilationInfos { get; }
18+
public bool IsStandalone => Mode.HasFlag(ExtractorMode.Standalone);
1819

1920
/// <summary>
2021
/// Creates a new extractor instance for one compilation unit.

0 commit comments

Comments
 (0)