using System.Linq;
using System.Reflection;
public static class AssemblyInfo
{
/// Gets the git hash value from the assembly
/// or null if it cannot be found.
public static string GetGitRevision()
{
var asm = typeof(AssemblyInfo).Assembly;
var attrs = asm.GetCustomAttributes();
return attrs.FirstOrDefault(a => a.Key == "GitRevision")?.Value;
}
/// Gets the git branch name from the assembly
/// or null if it cannot be found.
public static string GetGitBranch()
{
var asm = typeof(AssemblyInfo).Assembly;
var attrs = asm.GetCustomAttributes();
return attrs.FirstOrDefault(a => a.Key == "GitBranch")?.Value;
}
/// Gets the build platform and configuration
public static string GetBuildString()
{
string retVal = "Unknown";
#if WINDOWS
retVal = "Windows";
#elif OSX
retVal = "Mac";
#elif LINUX
retVal = "Linux";
#endif
#if DEBUG
retVal = "Debug" + retVal;
#elif UNSTABLE
retVal = "Unstable" + retVal;
#else
retVal = "Release" + retVal;
#endif
return retVal;
}
}