diff --git a/Snowflake.Data/Core/Tools/Diagnostics.cs b/Snowflake.Data/Core/Tools/Diagnostics.cs index 0e9f5b0dd..22d37daec 100644 --- a/Snowflake.Data/Core/Tools/Diagnostics.cs +++ b/Snowflake.Data/Core/Tools/Diagnostics.cs @@ -1,5 +1,4 @@ using System; -using System.Diagnostics; using System.Reflection; using System.Runtime; using System.Runtime.InteropServices; @@ -18,22 +17,31 @@ internal class Diagnostics private static string GetDiagnosticInfo() { StringBuilder info = new StringBuilder("System Diagnostics:\n"); - info.AppendLine($"{"OS", PadRight}: {OsName()}"); - info.AppendLine($"{"OS Description", PadRight}: {RuntimeInformation.OSDescription}"); - info.AppendLine($"{"OS Architecture", PadRight}: {RuntimeInformation.OSArchitecture}"); - info.AppendLine($"{"OS Version", PadRight}: {Environment.OSVersion}"); - info.AppendLine($"{"OS x64", PadRight}: {Environment.Is64BitOperatingSystem}"); - info.AppendLine($"{"Processor Architecture", PadRight}: {RuntimeInformation.ProcessArchitecture}"); - info.AppendLine($"{"Processor Count", PadRight}: {Environment.ProcessorCount}"); - info.AppendLine($"{".NET Framework", PadRight}: {RuntimeInformation.FrameworkDescription}"); - info.AppendLine($"{"CLR Runtime Version", PadRight}: {Environment.Version}"); - info.AppendLine($"{"App x64", PadRight}: {Environment.Is64BitProcess}"); - info.AppendLine($"{"GC Server Mode", PadRight}: {GCSettings.IsServerGC}"); - info.AppendLine($"{"GC LOH Compaction Mode", PadRight}: {GCSettings.LargeObjectHeapCompactionMode}"); - info.AppendLine($"{"GC Latency Mode", PadRight}: {GCSettings.LatencyMode}"); - info.AppendLine($"{"GC Total Memory", PadRight}: {GC.GetTotalMemory(false)}"); - AppendAssemblyInfo(info, Assembly.GetEntryAssembly(), "App"); - AppendAssemblyInfo(info, Assembly.GetExecutingAssembly(), "Driver"); + try + { + info.AppendLine($"{"OS",PadRight}: {OsName()}"); + info.AppendLine($"{"OS Description",PadRight}: {RuntimeInformation.OSDescription}"); + info.AppendLine($"{"OS Architecture",PadRight}: {RuntimeInformation.OSArchitecture}"); + info.AppendLine($"{"OS Version",PadRight}: {Environment.OSVersion}"); + info.AppendLine($"{"OS x64",PadRight}: {Environment.Is64BitOperatingSystem}"); + info.AppendLine($"{"Processor Architecture",PadRight}: {RuntimeInformation.ProcessArchitecture}"); + info.AppendLine($"{"Processor Count",PadRight}: {Environment.ProcessorCount}"); + info.AppendLine($"{".NET Framework",PadRight}: {RuntimeInformation.FrameworkDescription}"); + info.AppendLine($"{"CLR Runtime Version",PadRight}: {Environment.Version}"); + info.AppendLine($"{"App x64",PadRight}: {Environment.Is64BitProcess}"); + info.AppendLine($"{"GC Server Mode",PadRight}: {GCSettings.IsServerGC}"); + info.AppendLine($"{"GC LOH Compaction Mode",PadRight}: {GCSettings.LargeObjectHeapCompactionMode}"); + info.AppendLine($"{"GC Latency Mode",PadRight}: {GCSettings.LatencyMode}"); + info.AppendLine($"{"GC Total Memory",PadRight}: {GC.GetTotalMemory(false)}"); + AppendAssemblyInfo(info, Assembly.GetEntryAssembly(), "App"); + AppendAssemblyInfo(info, Assembly.GetExecutingAssembly(), "Driver"); + } + catch (Exception exception) + { + var errorMessage = $"Error caught while collecting diagnostic info: {exception.Message}"; + s_logger.Error(errorMessage, exception); + info.AppendLine(errorMessage); + } return info.ToString(); } @@ -41,10 +49,8 @@ private static void AppendAssemblyInfo(StringBuilder info, Assembly assembly, st { if (assembly != null) { - var assemblyVersion = FileVersionInfo.GetVersionInfo(assembly.Location); - info.AppendLine($"{assemblyTag + " Name", PadRight}: {assemblyVersion.InternalName}"); - info.AppendLine($"{assemblyTag + " File", PadRight}: {assemblyVersion.FileName}"); - info.AppendLine($"{assemblyTag + " Version", PadRight}: {assemblyVersion.FileVersion}"); + info.AppendLine($"{assemblyTag + "Name",PadRight}: {assembly.GetName().Name}"); + info.AppendLine($"{assemblyTag + "Version",PadRight}: {assembly.GetName().Version}"); } }