update to was 1.2.0 preview

This commit is contained in:
DismissedLight
2022-10-06 11:59:17 +08:00
parent b545c0d09b
commit 2f1981108e
2 changed files with 11 additions and 17 deletions

View File

@@ -2,7 +2,9 @@
// Licensed under the MIT license.
using Microsoft.UI.Xaml;
using Snap.Hutao.Core.Diagnostics;
using Snap.Hutao.Core.Logging;
using System.Diagnostics;
using System.IO;
namespace Snap.Hutao.Core.Exception;
@@ -25,26 +27,15 @@ internal class ExceptionRecorder
application.UnhandledException += OnAppUnhandledException;
application.DebugSettings.BindingFailed += OnXamlBindingFailed;
AppDomain.CurrentDomain.UnhandledException += OnCurrentDomainUnhandledException;
}
private void OnCurrentDomainUnhandledException(object sender, System.UnhandledExceptionEventArgs e)
{
logger.LogError(EventIds.UnhandledException, e.ExceptionObject as System.Exception, "未经处理的异常");
foreach (ILoggerProvider provider in Ioc.Default.GetRequiredService<IEnumerable<ILoggerProvider>>())
{
provider.Dispose();
}
}
private void OnAppUnhandledException(object? sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e)
{
// string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
// string fileName = $"ex-{DateTimeOffset.Now:yyyyMMddHHmmssffff}.txt";
// File.WriteAllText(Path.Combine(path, fileName), $"{e.Exception}\r\n{e.Exception.StackTrace}");
logger.LogError(EventIds.UnhandledException, e.Exception, "未经处理的异常");
string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
File.WriteAllText(Path.Combine(path, "Excpetion.txt"), e.Exception?.ToString());
foreach (ILoggerProvider provider in Ioc.Default.GetRequiredService<IEnumerable<ILoggerProvider>>())
{
provider.Dispose();

View File

@@ -110,9 +110,12 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Validation" Version="17.0.64" />
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.2.46-beta" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.1" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.1.5" />
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.2.63-beta">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.25211-preview" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.2.220930.4-preview2" />
<PackageReference Include="MiniExcel" Version="1.28.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435">
<PrivateAssets>all</PrivateAssets>