Skip to content

Commit 33eb691

Browse files
committed
C#: Change ID of buildless output assembly
1 parent 546b0a9 commit 33eb691

File tree

1 file changed

+14
-5
lines changed
  • csharp/extractor/Semmle.Extraction.CSharp/Entities

1 file changed

+14
-5
lines changed

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,20 @@ internal class Assembly : Extraction.Entities.Location
99

1010
private readonly string assemblyPath;
1111
private readonly IAssemblySymbol assembly;
12+
private readonly bool isOutputAssembly;
1213

1314
private Assembly(Context cx, Microsoft.CodeAnalysis.Location? init)
1415
: base(cx, init)
1516
{
16-
if (init is null)
17+
isOutputAssembly = init is null;
18+
if (isOutputAssembly)
1719
{
18-
// This is the output assembly
1920
assemblyPath = cx.Extractor.OutputPath;
2021
assembly = cx.Compilation.Assembly;
2122
}
2223
else
2324
{
24-
assembly = init.MetadataModule!.ContainingAssembly;
25+
assembly = init!.MetadataModule!.ContainingAssembly;
2526
var identity = assembly.Identity;
2627
var idString = identity.Name + " " + identity.Version;
2728
assemblyPath = cx.Extractor.GetAssemblyFile(idString);
@@ -68,8 +69,16 @@ public static Assembly CreateOutputAssembly(Context cx)
6869

6970
public override void WriteId(EscapingTextWriter trapFile)
7071
{
71-
trapFile.Write(assembly.ToString());
72-
if (!(assemblyPath is null))
72+
if (isOutputAssembly && Context.Extractor.Mode.HasFlag(ExtractorMode.Standalone))
73+
{
74+
trapFile.Write("buildlessOutputAssembly");
75+
}
76+
else
77+
{
78+
trapFile.Write(assembly.ToString());
79+
}
80+
81+
if (assemblyPath is not null)
7382
{
7483
trapFile.Write("#file:///");
7584
trapFile.Write(assemblyPath.Replace("\\", "/"));

0 commit comments

Comments
 (0)