feat: add Util.GetGitHash()

This commit is contained in:
goat 2021-04-11 18:50:58 +02:00
parent 1e9653baa4
commit 043509b6b0
No known key found for this signature in database
GPG key ID: F18F057873895461

View file

@ -1,4 +1,5 @@
using System;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
@ -13,11 +14,31 @@ namespace Dalamud
/// </summary>
public static class Util
{
private static string gitHashInternal;
/// <summary>
/// Gets the assembly version of Dalamud.
/// </summary>
public static string AssemblyVersion { get; } = Assembly.GetAssembly(typeof(ChatHandlers)).GetName().Version.ToString();
/// <summary>
/// Gets the git hash value from the assembly
/// or null if it cannot be found.
/// </summary>
/// <returns>The git hash of the assembly.</returns>
public static string GetGitHash()
{
if (gitHashInternal != null)
return gitHashInternal;
var asm = typeof(Util).Assembly;
var attrs = asm.GetCustomAttributes<AssemblyMetadataAttribute>();
gitHashInternal = attrs.FirstOrDefault(a => a.Key == "GitHash")?.Value;
return gitHashInternal;
}
/// <summary>
/// Read memory from an offset and hexdump them via Serilog.
/// </summary>