public override string ToString()

in sources/Google.Solutions.IapDesktop.Application/Diagnostics/BugReport.cs [63:118]


        public override string ToString()
        {
            var text = new StringBuilder();

            if (this.exception != null)
            {
                for (var ex = this.exception; ex != null; ex = ex.InnerException)
                {
                    text.Append(ex.ToString(ExceptionFormatOptions.IncludeOffsets));
                    text.Append("\n\n");
                }

                if (this.exception is ReflectionTypeLoadException tle)
                {
                    text.Append("\nLoader Exceptions:\n");
                    foreach (var e in tle.LoaderExceptions)
                    {
                        text.Append(e.ToString(ExceptionFormatOptions.IncludeOffsets));
                        text.Append("\n\n");
                    }
                }
            }

            if (this.WindowMessageTrace != null)
            {
                text.Append("\nMessage history:\n");
                text.Append(this.WindowMessageTrace);
                text.AppendLine();
            }

            if (this.SourceWindow == null)
            {
                //
                // Ignore.
                //
            }
            else if (this.SourceWindow is Control control &&
                control.FindForm() is var form &&
                form != null)
            {
                text.Append($"Window: {form.Name} ({control.GetType().Name})\n");
                text.Append($"Control: {control.Name} ({control.GetType().Name})\n");
            }
            else if (this.SourceWindow.Handle == Process.GetCurrentProcess().MainWindowHandle)
            {
                text.Append("Window: main\n");
            }

            text.Append($"Source: {this.source?.Name ?? string.Empty}\n");
            text.Append($"Version: {GetType().Assembly.GetName().Version}\n");
            text.Append($"Runtime: {ClrVersion.Version} ({ProcessEnvironment.ProcessArchitecture})\n");
            text.Append($"OS: {Environment.OSVersion} ({ProcessEnvironment.NativeArchitecture})\n");
            text.Append($"DPI: {DeviceCapabilities.Current.Dpi}/{DeviceCapabilities.System.Dpi}\n");

            return text.ToString();
        }