static Manager() { illegalCharactersPattern = new Regex(IllegalCharacters); mapper = new ObjectWriter(); DefaultOptions = ManagerOptions.Default; // // Note: Environment.SpecialFolder.LocalApplicationData returns null on Azure (and possibly other Windows Server environments) // and this is only needed by the default constructor or when accessing the SharedInstanced // So, let's only set it only when GetFolderPath returns something and allow the directory to be // manually specified via the ctor that accepts a DirectoryInfo #if __UNITY__ string defaultDirectoryPath = Unity.UnityMainThreadScheduler.PersistentDataPath; #else var defaultDirectoryPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); #endif if (!StringEx.IsNullOrWhiteSpace(defaultDirectoryPath)) { defaultDirectory = new DirectoryInfo(defaultDirectoryPath); } var gitVersion = String.Empty; var branchName = String.Empty; ReadVersion(Assembly.GetExecutingAssembly(), out branchName, out gitVersion); var infoVersion = Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute; bool unofficial = infoVersion == null || infoVersion.InformationalVersion.StartsWith("0.0.0"); #if DEBUG var versionNumber = infoVersion == null || infoVersion.InformationalVersion.StartsWith("0.0.0") ? "Unofficial Debug" : infoVersion.InformationalVersion + " Debug"; #else var versionNumber = infoVersion == null || infoVersion.InformationalVersion.StartsWith("0.0.0") ? "Unofficial" : infoVersion.InformationalVersion; #endif if (unofficial) { VersionString = String.Format(".NET {0}/{1} {2} ({3})/{4}", PLATFORM, Platform.Architecture, versionNumber, branchName.Replace('/', '\\'), gitVersion.TrimEnd()); } else { VersionString = String.Format(".NET {0}/{1} {2}/{3}", PLATFORM, Platform.Architecture, versionNumber, gitVersion.TrimEnd()); } Log.To.NoDomain.I(TAG, "Starting Manager version: {0}", VersionString); AppDomain.CurrentDomain.AssemblyLoad += (sender, args) => { if (ReadVersion(args.LoadedAssembly, out branchName, out gitVersion)) { Log.To.NoDomain.I("AssemblyLoad", "Loaded assembly {0} was built at commit {1}", args.LoadedAssembly.FullName, gitVersion); } }; foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { if (ReadVersion(assembly, out branchName, out gitVersion)) { Log.To.NoDomain.I("AssemblyLoad", "Loaded assembly {0} was built at commit {1}", assembly.FullName, gitVersion); } } }