mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-14 12:44:16 +01:00
feat: add Util.GetGitHash()
This commit is contained in:
parent
1e9653baa4
commit
043509b6b0
1 changed files with 21 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
@ -13,11 +14,31 @@ namespace Dalamud
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class Util
|
public static class Util
|
||||||
{
|
{
|
||||||
|
private static string gitHashInternal;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the assembly version of Dalamud.
|
/// Gets the assembly version of Dalamud.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string AssemblyVersion { get; } = Assembly.GetAssembly(typeof(ChatHandlers)).GetName().Version.ToString();
|
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>
|
/// <summary>
|
||||||
/// Read memory from an offset and hexdump them via Serilog.
|
/// Read memory from an offset and hexdump them via Serilog.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue