Skip to content

Commit

Permalink
Merge pull request #90 from DGP-Studio/winui-120
Browse files Browse the repository at this point in the history
update to was 1.2.0 preview
  • Loading branch information
Lightczx authored Oct 6, 2022
2 parents b545c0d + 2f19811 commit 560068c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
19 changes: 5 additions & 14 deletions src/Snap.Hutao/Snap.Hutao/Core/Exception/ExceptionRecorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -25,26 +27,15 @@ public ExceptionRecorder(Application application, ILogger logger)

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();
Expand Down
9 changes: 6 additions & 3 deletions src/Snap.Hutao/Snap.Hutao/Snap.Hutao.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 560068c

Please sign in to comment.