2 using System.Reflection;
3 using System.Runtime.CompilerServices;
5 [assembly:InternalsVisibleTo(
"WindowsTest"),
6 InternalsVisibleTo(
"MacTest"),
7 InternalsVisibleTo(
"LinuxTest")]
9 public static class AssemblyInfo
11 public static readonly
string GitRevision;
12 public static readonly
string GitBranch;
13 public static readonly
string ProjectDir;
14 public static readonly
string BuildString;
23 public enum Configuration
31 public const Platform CurrentPlatform = Platform.Windows;
33 public const Platform CurrentPlatform = Platform.MacOS;
35 public const Platform CurrentPlatform = Platform.Linux;
37 #error Unknown platform
41 public const Configuration CurrentConfiguration = Configuration.Debug;
43 public const Configuration CurrentConfiguration = Configuration.Unstable;
45 public const Configuration CurrentConfiguration = Configuration.Release;
50 var
asm = typeof(AssemblyInfo).Assembly;
51 var attrs =
asm.GetCustomAttributes<AssemblyMetadataAttribute>();
53 GitRevision = attrs.FirstOrDefault(a => a.Key ==
"GitRevision")?.Value;
55 GitBranch = attrs.FirstOrDefault(a => a.Key ==
"GitBranch")?.Value;
57 ProjectDir = attrs.FirstOrDefault(a => a.Key ==
"ProjectDir")?.Value;
58 if (ProjectDir.Last() ==
'/' || ProjectDir.Last() ==
'\\') { ProjectDir = ProjectDir.Substring(0, ProjectDir.Length - 1); }
59 string[] dirSplit = ProjectDir.Split(
'/',
'\\');
60 ProjectDir =
string.Join(ProjectDir.Contains(
'/') ?
'/' :
'\\', dirSplit.Take(dirSplit.Length - 2));
62 BuildString = $
"{CurrentConfiguration}{CurrentPlatform}";
65 public static string CleanupStackTrace(
this string stackTrace)
67 return stackTrace.Replace(ProjectDir,
"<DEV>");