Skip to content

Commit

Permalink
Changed the CompilerIdentifier label from the previous hardcoded mess…
Browse files Browse the repository at this point in the history
…age to programmatically retrieve the current version. (dotnet#51352)
  • Loading branch information
ivdiazsa authored Apr 16, 2021
1 parent ff17846 commit d97ef9f
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Reflection;
using System.Text;
using Internal.Text;
using Internal.TypeSystem;
Expand All @@ -9,8 +10,6 @@ namespace ILCompiler.DependencyAnalysis.ReadyToRun
{
internal class CompilerIdentifierNode : HeaderTableNode
{
private static readonly string _compilerIdentifier = "CoreRT Ready-To-Run Compiler";

public override ObjectNodeSection Section => ObjectNodeSection.ReadOnlyDataSection;

public override int ClassCode => 230053202;
Expand All @@ -25,12 +24,21 @@ public override void AppendMangledName(NameMangler nameMangler, Utf8StringBuilde
sb.Append("__ReadyToRunHeader_CompilerIdentifier");
}

private string GetCompilerVersion()
{
return Assembly
.GetExecutingAssembly()
.GetCustomAttribute<AssemblyFileVersionAttribute>()
.Version;
}

public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
{
ObjectDataBuilder builder = new ObjectDataBuilder(factory, relocsOnly);
string compilerIdentifier = $"Crossgen2 {GetCompilerVersion()}";
builder.RequireInitialPointerAlignment();
builder.AddSymbol(this);
builder.EmitBytes(Encoding.ASCII.GetBytes(_compilerIdentifier));
builder.EmitBytes(Encoding.ASCII.GetBytes(compilerIdentifier));
return builder.ToObjectData();
}
}
Expand Down

0 comments on commit d97ef9f

Please sign in to comment.