Client LuaCsForBarotrauma
AssemblyInfo.cs
1 using System.Linq;
2 using System.Reflection;
3 using System.Runtime.CompilerServices;
4 
5 [assembly:InternalsVisibleTo("WindowsTest"),
6  InternalsVisibleTo("MacTest"),
7  InternalsVisibleTo("LinuxTest")]
8 
9 public static class AssemblyInfo
10 {
11  public static readonly string GitRevision;
12  public static readonly string GitBranch;
13  public static readonly string ProjectDir;
14  public static readonly string BuildString;
15 
16  public enum Platform
17  {
18  Windows,
19  MacOS,
20  Linux
21  }
22 
23  public enum Configuration
24  {
25  Release,
26  Unstable,
27  Debug
28  }
29 
30 #if WINDOWS
31  public const Platform CurrentPlatform = Platform.Windows;
32 #elif OSX
33  public const Platform CurrentPlatform = Platform.MacOS;
34 #elif LINUX
35  public const Platform CurrentPlatform = Platform.Linux;
36 #else
37  #error Unknown platform
38 #endif
39 
40 #if DEBUG
41  public const Configuration CurrentConfiguration = Configuration.Debug;
42 #elif UNSTABLE
43  public const Configuration CurrentConfiguration = Configuration.Unstable;
44 #else
45  public const Configuration CurrentConfiguration = Configuration.Release;
46 #endif
47 
48  static AssemblyInfo()
49  {
50  var asm = typeof(AssemblyInfo).Assembly;
51  var attrs = asm.GetCustomAttributes<AssemblyMetadataAttribute>();
52 
53  GitRevision = attrs.FirstOrDefault(a => a.Key == "GitRevision")?.Value;
54 
55  GitBranch = attrs.FirstOrDefault(a => a.Key == "GitBranch")?.Value;
56 
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));
61 
62  BuildString = $"{CurrentConfiguration}{CurrentPlatform}";
63  }
64 
65  public static string CleanupStackTrace(this string stackTrace)
66  {
67  return stackTrace.Replace(ProjectDir, "<DEV>");
68  }
69 }