C#: Change ID of buildless output assembly

This commit is contained in:
Tamas Vajk
2024-03-08 11:20:04 +01:00
parent 546b0a9a89
commit 33eb69164c

View File

@@ -9,19 +9,20 @@ namespace Semmle.Extraction.CSharp.Entities
private readonly string assemblyPath;
private readonly IAssemblySymbol assembly;
private readonly bool isOutputAssembly;
private Assembly(Context cx, Microsoft.CodeAnalysis.Location? init)
: base(cx, init)
{
if (init is null)
isOutputAssembly = init is null;
if (isOutputAssembly)
{
// This is the output assembly
assemblyPath = cx.Extractor.OutputPath;
assembly = cx.Compilation.Assembly;
}
else
{
assembly = init.MetadataModule!.ContainingAssembly;
assembly = init!.MetadataModule!.ContainingAssembly;
var identity = assembly.Identity;
var idString = identity.Name + " " + identity.Version;
assemblyPath = cx.Extractor.GetAssemblyFile(idString);
@@ -68,8 +69,16 @@ namespace Semmle.Extraction.CSharp.Entities
public override void WriteId(EscapingTextWriter trapFile)
{
trapFile.Write(assembly.ToString());
if (!(assemblyPath is null))
if (isOutputAssembly && Context.Extractor.Mode.HasFlag(ExtractorMode.Standalone))
{
trapFile.Write("buildlessOutputAssembly");
}
else
{
trapFile.Write(assembly.ToString());
}
if (assemblyPath is not null)
{
trapFile.Write("#file:///");
trapFile.Write(assemblyPath.Replace("\\", "/"));