mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Merge pull request #15854 from tamasvajk/buildless/change-assembly-id
C#: Change ID of buildless output assembly
This commit is contained in:
@@ -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);
|
||||
@@ -32,8 +33,13 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
{
|
||||
if (assemblyPath is not null)
|
||||
{
|
||||
trapFile.assemblies(this, File.Create(Context, assemblyPath), assembly.ToString() ?? "",
|
||||
assembly.Identity.Name, assembly.Identity.Version.ToString());
|
||||
var isBuildlessOutputAssembly = isOutputAssembly && Context.Extractor.Mode.HasFlag(ExtractorMode.Standalone);
|
||||
var identifier = isBuildlessOutputAssembly
|
||||
? ""
|
||||
: assembly.ToString() ?? "";
|
||||
var name = isBuildlessOutputAssembly ? "" : assembly.Identity.Name;
|
||||
var version = isBuildlessOutputAssembly ? "" : assembly.Identity.Version.ToString();
|
||||
trapFile.assemblies(this, File.Create(Context, assemblyPath), identifier, name, version);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,8 +74,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("\\", "/"));
|
||||
|
||||
Reference in New Issue
Block a user