mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 18:57:19 +02:00
Refactoring error report
1. fix #627 2. fix #646 3. remove exceptionless
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace Wox.CrashReporter
|
||||
namespace Wox
|
||||
{
|
||||
public class CrashReporter
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Wox.Helper
|
||||
public static void Report(Exception e)
|
||||
{
|
||||
Log.Fatal(e);
|
||||
new CrashReporter.CrashReporter(e).Show();
|
||||
new CrashReporter(e).Show();
|
||||
}
|
||||
|
||||
public static void UnhandledExceptionHandle(object sender, UnhandledExceptionEventArgs e)
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using Exceptionless.Configuration;
|
||||
|
||||
[assembly: AssemblyTitle("Wox")]
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None,
|
||||
ResourceDictionaryLocation.SourceAssembly
|
||||
)]
|
||||
[assembly: Exceptionless("e0b256fbe9384498ba89aae2a6b7f8ab")]
|
||||
)]
|
||||
@@ -1,4 +1,4 @@
|
||||
<Window x:Class="Wox.CrashReporter.ReportWindow"
|
||||
<Window x:Class="Wox.ReportWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
@@ -12,68 +12,12 @@
|
||||
Height="455"
|
||||
Title="{DynamicResource reportWindow_wox_got_an_error}"
|
||||
d:DesignHeight="300" d:DesignWidth="600" x:ClassModifier="internal">
|
||||
<StackPanel>
|
||||
<TabControl >
|
||||
<TabItem Header="{DynamicResource reportWindow_general}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100"></ColumnDefinition>
|
||||
<ColumnDefinition></ColumnDefinition>
|
||||
<ColumnDefinition Width="40"></ColumnDefinition>
|
||||
<ColumnDefinition></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="80"></RowDefinition>
|
||||
<RowDefinition></RowDefinition>
|
||||
<RowDefinition></RowDefinition>
|
||||
<RowDefinition Height="200"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<Image Source="Images/crash_warning.png" Width="64"></Image>
|
||||
<RichTextBox Grid.Row="0" Grid.ColumnSpan="3" Grid.Column="1" IsReadOnly="True" x:Name="tbSummary"></RichTextBox>
|
||||
<TextBlock Padding="0 5 0 0" Grid.Row="1" Grid.Column="0" Text="{DynamicResource reportWindow_version}"></TextBlock>
|
||||
<TextBlock Padding="0 5 0 0" Grid.Row="1" Grid.Column="1" Text="Version" x:Name="tbVersion"></TextBlock>
|
||||
<TextBlock Padding="0 5 0 0" Grid.Row="1" Grid.Column="2" Text="{DynamicResource reportWindow_time}"></TextBlock>
|
||||
<TextBlock Padding="0 5 0 0" Grid.Row="1" Grid.Column="3" Text="10201211-21-21" x:Name="tbDatetime"></TextBlock>
|
||||
<TextBlock Padding="0 5 0 5" Grid.ColumnSpan="4" Grid.Row="2" Grid.Column="0" Text="{DynamicResource reportWindow_reproduce}"></TextBlock>
|
||||
<RichTextBox Grid.Row="3" Grid.ColumnSpan="4" Grid.Column="0" Background="#FFFFE1" x:Name="tbReproduceSteps"></RichTextBox>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Header="{DynamicResource reportWindow_exceptions}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="37*"/>
|
||||
<ColumnDefinition Width="547*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition></RowDefinition>
|
||||
<RowDefinition></RowDefinition>
|
||||
<RowDefinition></RowDefinition>
|
||||
<RowDefinition></RowDefinition>
|
||||
<RowDefinition></RowDefinition>
|
||||
<RowDefinition></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0" Text="{DynamicResource reportWindow_exception_type}" Padding="5" Grid.ColumnSpan="2"></TextBlock>
|
||||
<TextBox IsReadOnly="True" Grid.Row="1" Padding="5" x:Name="tbType" Grid.ColumnSpan="2"></TextBox>
|
||||
<TextBlock Grid.Row="2" Text="{DynamicResource reportWindow_source}" Padding="5" Grid.ColumnSpan="2"></TextBlock>
|
||||
<TextBox IsReadOnly="True" Grid.Row="3" Padding="5" x:Name="tbSource" Grid.ColumnSpan="2"></TextBox>
|
||||
<TextBlock Grid.Row="4" Text="{DynamicResource reportWindow_stack_trace}" Padding="5" Grid.ColumnSpan="2"></TextBlock>
|
||||
<RichTextBox Grid.Row="5" x:Name="tbStackTrace" Height="190" Grid.ColumnSpan="2" Margin="0,0,0,-0.001"></RichTextBox>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
|
||||
<Button x:Name="btnSend" Padding="8 3" Margin="8" Click="btnSend_Click">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Image Source="Images/crash_go.png" Margin="0 5 5 0"/>
|
||||
<Label Padding="0" Margin="0 10 0 0" x:Name="tbSendReport" Content="{DynamicResource reportWindow_send_report}"></Label>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button x:Name="btnCancel" Padding="8 3" Margin="8" Click="btnCancel_Click">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Image Source="Images/crash_stop.png" Margin="0 5 5 0"/>
|
||||
<Label Padding="0" Margin="0 10 0 0" Content="{DynamicResource reportWindow_cancel}"></Label>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<RichTextBox x:Name="ErrorTextbox"
|
||||
IsDocumentEnabled="True"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
HorizontalScrollBarVisibility="Auto"
|
||||
FontSize="14"
|
||||
Margin="10"
|
||||
BorderThickness="0"/>
|
||||
|
||||
</Window>
|
||||
|
||||
@@ -1,63 +1,66 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Documents;
|
||||
using Exceptionless;
|
||||
using Wox.Core.Resource;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Infrastructure.Logger;
|
||||
|
||||
namespace Wox.CrashReporter
|
||||
namespace Wox
|
||||
{
|
||||
internal partial class ReportWindow
|
||||
{
|
||||
private Exception exception;
|
||||
|
||||
public ReportWindow(Exception exception)
|
||||
{
|
||||
this.exception = exception;
|
||||
InitializeComponent();
|
||||
ErrorTextbox.Document.Blocks.FirstBlock.Margin = new Thickness(0);
|
||||
SetException(exception);
|
||||
}
|
||||
|
||||
private void SetException(Exception exception)
|
||||
{
|
||||
tbSummary.AppendText(exception.Message);
|
||||
tbVersion.Text = Infrastructure.Constant.Version;
|
||||
tbDatetime.Text = DateTime.Now.ToString();
|
||||
tbStackTrace.AppendText(exception.StackTrace);
|
||||
tbSource.Text = exception.Source;
|
||||
tbType.Text = exception.GetType().ToString();
|
||||
string path = Path.Combine(Constant.DataDirectory, Log.DirectoryName, Constant.Version);
|
||||
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($"Wox version: {Constant.Version}");
|
||||
content.AppendLine($"OS Version: {Environment.OSVersion.VersionString}");
|
||||
content.AppendLine($"Date: {DateTime.Now.ToString(CultureInfo.InvariantCulture)}");
|
||||
content.AppendLine("Exception:");
|
||||
content.AppendLine(exception.Source);
|
||||
content.AppendLine(exception.GetType().ToString());
|
||||
content.AppendLine(exception.Message);
|
||||
content.AppendLine(exception.StackTrace);
|
||||
paragraph = new Paragraph();
|
||||
paragraph.Inlines.Add(content.ToString());
|
||||
ErrorTextbox.Document.Blocks.Add(paragraph);
|
||||
}
|
||||
|
||||
private void btnSend_Click(object sender, RoutedEventArgs e)
|
||||
private Paragraph Hyperlink(string textBeforeUrl, string url)
|
||||
{
|
||||
string sendingMsg = InternationalizationManager.Instance.GetTranslation("reportWindow_sending");
|
||||
tbSendReport.Content = sendingMsg;
|
||||
btnSend.IsEnabled = false;
|
||||
SendReport();
|
||||
}
|
||||
var paragraph = new Paragraph();
|
||||
paragraph.Margin = new Thickness(0);
|
||||
|
||||
private void SendReport()
|
||||
{
|
||||
Hide();
|
||||
Task.Run(() =>
|
||||
{
|
||||
string reproduceSteps = new TextRange(tbReproduceSteps.Document.ContentStart, tbReproduceSteps.Document.ContentEnd).Text;
|
||||
exception.ToExceptionless()
|
||||
.SetUserDescription(reproduceSteps)
|
||||
.Submit();
|
||||
ExceptionlessClient.Current.ProcessQueue();
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
Close();
|
||||
});
|
||||
});
|
||||
}
|
||||
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);
|
||||
|
||||
private void btnCancel_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
paragraph.Inlines.Add(textBeforeUrl);
|
||||
paragraph.Inlines.Add(link);
|
||||
paragraph.Inlines.Add("\n");
|
||||
|
||||
return paragraph;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,9 @@
|
||||
<PropertyGroup>
|
||||
<StartupObject>Wox.App</StartupObject>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="DeltaCompressionDotNet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1d14d6e5194e7f4a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\DeltaCompressionDotNet.1.0.0\lib\net45\DeltaCompressionDotNet.dll</HintPath>
|
||||
@@ -72,14 +75,6 @@
|
||||
<HintPath>..\packages\DeltaCompressionDotNet.1.0.0\lib\net45\DeltaCompressionDotNet.PatchApi.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Exceptionless, Version=1.5.2121.0, Culture=neutral, PublicKeyToken=fc181f0a46f65747, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Exceptionless.1.5.2121\lib\net45\Exceptionless.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Exceptionless.Models, Version=1.5.2121.0, Culture=neutral, PublicKeyToken=fc181f0a46f65747, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Exceptionless.1.5.2121\lib\net45\Exceptionless.Models.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\squirrel.windows.1.4.0\lib\Net45\ICSharpCode.SharpZipLib.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
@@ -157,9 +152,11 @@
|
||||
<Compile Include="..\SolutionAssemblyInfo.cs">
|
||||
<Link>Properties\SolutionAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="CrashReporter.cs" />
|
||||
<Compile Include="Helper\VisibilityExtensions.cs" />
|
||||
<Compile Include="Helper\SingletonWindowOpener.cs" />
|
||||
<Compile Include="PublicAPIInstance.cs" />
|
||||
<Compile Include="ReportWindow.xaml.cs" />
|
||||
<Compile Include="ResultListBox.xaml.cs">
|
||||
<DependentUpon>ResultListBox.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -209,6 +206,7 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<None Include="App.config" />
|
||||
<None Include="app.manifest" />
|
||||
<None Include="Languages\zh-cn.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
@@ -273,6 +271,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="ReportWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="ResultListBox.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
@@ -352,10 +354,6 @@
|
||||
<Project>{B749F0DB-8E75-47DB-9E5E-265D16D0C0D2}</Project>
|
||||
<Name>Wox.Core</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Wox.CrashReporter\Wox.CrashReporter.csproj">
|
||||
<Project>{2FEB2298-7653-4009-B1EA-FFFB1A768BCC}</Project>
|
||||
<Name>Wox.CrashReporter</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Wox.Infrastructure\Wox.Infrastructure.csproj">
|
||||
<Project>{4fd29318-a8ab-4d8f-aa47-60bc241b8da3}</Project>
|
||||
<Name>Wox.Infrastructure</Name>
|
||||
|
||||
74
Wox/app.manifest
Normal file
74
Wox/app.manifest
Normal file
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<!-- UAC Manifest Options
|
||||
If you want to change the Windows User Account Control level replace the
|
||||
requestedExecutionLevel node with one of the following.
|
||||
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
|
||||
|
||||
Specifying requestedExecutionLevel element will disable file and registry virtualization.
|
||||
Remove this element if your application requires this virtualization for backwards
|
||||
compatibility.
|
||||
-->
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- A list of the Windows versions that this application has been tested on and is
|
||||
is designed to work with. Uncomment the appropriate elements and Windows will
|
||||
automatically selected the most compatible environment. -->
|
||||
|
||||
<!-- Windows Vista -->
|
||||
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />
|
||||
|
||||
<!-- Windows 7 -->
|
||||
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
|
||||
|
||||
<!-- Windows 8 -->
|
||||
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
|
||||
|
||||
<!-- Windows 8.1 -->
|
||||
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />
|
||||
|
||||
<!-- Windows 10 -->
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
|
||||
|
||||
</application>
|
||||
</compatibility>
|
||||
|
||||
<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
|
||||
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
|
||||
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
|
||||
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. -->
|
||||
<!--
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
-->
|
||||
|
||||
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
|
||||
</assembly>
|
||||
@@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="DeltaCompressionDotNet" version="1.0.0" targetFramework="net452" />
|
||||
<package id="Exceptionless" version="1.5.2121" targetFramework="net452" />
|
||||
<package id="InputSimulator" version="1.0.4.0" targetFramework="net452" />
|
||||
<package id="JetBrains.Annotations" version="10.1.4" targetFramework="net452" />
|
||||
<package id="Mono.Cecil" version="0.9.6.1" targetFramework="net452" />
|
||||
|
||||
Reference in New Issue
Block a user