From b89d6d78ef4dd0e4ebc2109c7331e2461e11e981 Mon Sep 17 00:00:00 2001 From: ryanbodrug-microsoft <56318517+ryanbodrug-microsoft@users.noreply.github.com> Date: Thu, 18 Jun 2020 09:08:52 -0700 Subject: [PATCH] Fix or the following warning. Removing unused ReportWindow from Launcher Warning CA1812 ReportWindow is an internal class that is apparently never instantiated. If so, remove the code from the assembly. If this class is intended to contain only static members, make it static (Shared in Visual Basic). PowerLauncher C:\Repos\PowerToys\src\modules\launcher\PowerLauncher\ReportWindow.xaml.cs 15 Active --- .../launcher/PowerLauncher/ReportWindow.xaml | 23 ------- .../PowerLauncher/ReportWindow.xaml.cs | 63 ------------------- 2 files changed, 86 deletions(-) delete mode 100644 src/modules/launcher/PowerLauncher/ReportWindow.xaml delete mode 100644 src/modules/launcher/PowerLauncher/ReportWindow.xaml.cs diff --git a/src/modules/launcher/PowerLauncher/ReportWindow.xaml b/src/modules/launcher/PowerLauncher/ReportWindow.xaml deleted file mode 100644 index ea9d52fdce..0000000000 --- a/src/modules/launcher/PowerLauncher/ReportWindow.xaml +++ /dev/null @@ -1,23 +0,0 @@ - - - - diff --git a/src/modules/launcher/PowerLauncher/ReportWindow.xaml.cs b/src/modules/launcher/PowerLauncher/ReportWindow.xaml.cs deleted file mode 100644 index cb1388688e..0000000000 --- a/src/modules/launcher/PowerLauncher/ReportWindow.xaml.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Text; -using System.Linq; -using System.Windows; -using System.Windows.Documents; -using Wox.Helper; -using Wox.Infrastructure; -using Wox.Infrastructure.Logger; - -namespace PowerLauncher -{ - internal partial class ReportWindow - { - public ReportWindow(Exception exception) - { - InitializeComponent(); - ErrorTextbox.Document.Blocks.FirstBlock.Margin = new Thickness(0); - SetException(exception); - } - - private void SetException(Exception exception) - { - string path = Log.CurrentLogDirectory; - var directory = new DirectoryInfo(path); - var log = directory.GetFiles().OrderByDescending(f => f.LastWriteTime).First(); - - var paragraph = Hyperlink("Please open new issue in: ", Constant.Issue); - paragraph.Inlines.Add($"1. upload log file: {log.FullName}\n"); - paragraph.Inlines.Add($"2. copy below exception message"); - ErrorTextbox.Document.Blocks.Add(paragraph); - - StringBuilder content = new StringBuilder(); - content.AppendLine(ErrorReporting.RuntimeInfo()); - content.AppendLine($"Date: {DateTime.Now.ToString(CultureInfo.InvariantCulture)}"); - content.AppendLine("Exception:"); - content.AppendLine(exception.ToString()); - paragraph = new Paragraph(); - paragraph.Inlines.Add(content.ToString()); - ErrorTextbox.Document.Blocks.Add(paragraph); - } - - private static Paragraph Hyperlink(string textBeforeUrl, string url) - { - var paragraph = new Paragraph(); - paragraph.Margin = new Thickness(0); - - var link = new Hyperlink { IsEnabled = true }; - link.Inlines.Add(url); - link.NavigateUri = new Uri(url); - link.RequestNavigate += (s, e) => Process.Start(e.Uri.ToString()); - link.Click += (s, e) => Process.Start(url); - - paragraph.Inlines.Add(textBeforeUrl); - paragraph.Inlines.Add(link); - paragraph.Inlines.Add("\n"); - - return paragraph; - } - } -}