Skip to content

Commit ede9bc4

Browse files
committed
Updated to WASDK 1.1
1 parent f1e7411 commit ede9bc4

File tree

5 files changed

+32
-19
lines changed

5 files changed

+32
-19
lines changed

SecureFolderFS.Backend/ViewModels/Dashboard/Navigation/NavigationItemViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ public sealed class NavigationItemViewModel
66

77
public int Index { get; init; }
88

9-
public Action<NavigationItemViewModel?>? NavigationAction { get; init; }
10-
119
public string? SectionName { get; init; }
10+
11+
public Action<NavigationItemViewModel?>? NavigationAction { get; init; }
1212
}
1313
}

SecureFolderFS.WinUI/App.xaml.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Microsoft.UI.Xaml;
22
using System;
3+
using System.Diagnostics;
34
using CommunityToolkit.Mvvm.DependencyInjection;
45
using Microsoft.Extensions.DependencyInjection;
56
using SecureFolderFS.Backend.Services;
@@ -51,6 +52,7 @@ private void EnsureEarlyApp()
5152
{
5253
// Configure exception handlers
5354
UnhandledException += App_UnhandledException;
55+
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
5456
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
5557

5658
// Configure IoC
@@ -94,14 +96,21 @@ private void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledEx
9496
LogException(e.Exception);
9597
}
9698

97-
private void LogException(Exception ex)
99+
private void CurrentDomain_UnhandledException(object sender, System.UnhandledExceptionEventArgs e)
98100
{
99-
LogExceptionToFile(ex);
101+
LogException(e.ExceptionObject as Exception);
100102
}
101103

102-
private void LogExceptionToFile(Exception ex)
104+
private void LogException(Exception? ex)
103105
{
104-
LoggingHelpers.SafeLogExceptionToFile(ex);
106+
var formattedException = ExceptionHelpers.FormatException(ex);
107+
108+
Debug.WriteLine(formattedException);
109+
Debugger.Break(); // Please check "Output Window" for exception details (View -> Output Window) (Ctr + Alt + O)
110+
111+
#if !DEBUG
112+
ExceptionHelpers.LogExceptionToFile(formattedException);
113+
#endif
105114
}
106115
}
107116
}

SecureFolderFS.WinUI/Helpers/LoggingHelpers.cs renamed to SecureFolderFS.WinUI/Helpers/ExceptionHelpers.cs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
namespace SecureFolderFS.WinUI.Helpers
77
{
8-
internal static class LoggingHelpers
8+
internal static class ExceptionHelpers
99
{
10-
public static void SafeLogExceptionToFile(Exception ex)
10+
public static string? FormatException(Exception? ex)
1111
{
12-
if (ex == null)
12+
if (ex is null)
1313
{
14-
return;
14+
return null;
1515
}
1616

1717
var exceptionString = string.Empty;
@@ -24,23 +24,28 @@ public static void SafeLogExceptionToFile(Exception ex)
2424
exceptionString += $">>> INNER {ex.InnerException}\n";
2525
exceptionString += $">>> SOURCE {ex.Source}\n\n";
2626

27-
LogToFile(exceptionString);
27+
return exceptionString;
2828
}
2929

30-
private static void LogToFile(string text)
30+
public static void LogExceptionToFile(string? formattedException)
3131
{
32+
if (formattedException is null)
33+
{
34+
return;
35+
}
36+
3237
try
3338
{
3439
var filePath = Path.Combine(ApplicationData.Current.LocalFolder.Path, Constants.Application.EXCEPTIONLOG_FILENAME);
3540

3641
var existing = File.ReadAllText(filePath);
37-
existing += text;
42+
existing += formattedException;
3843

3944
File.WriteAllText(filePath, existing);
4045
}
41-
catch (Exception e)
46+
catch (Exception ex)
4247
{
43-
Debug.WriteLine(e);
48+
Debug.WriteLine(ex);
4449
}
4550
}
4651
}

SecureFolderFS.WinUI/SecureFolderFS.WinUI.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@
9393
<PackageReference Include="Microsoft.AppCenter.Analytics" Version="4.5.1" />
9494
<PackageReference Include="Microsoft.AppCenter.Crashes" Version="4.5.1" />
9595
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
96-
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.1.0-preview3" />
97-
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22000.196" />
98-
<PackageReference Include="Syncfusion.Chart.WinUI" Version="20.1.0.52" />
96+
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.1.0" />
97+
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22000.197" />
98+
<PackageReference Include="Syncfusion.Chart.WinUI" Version="20.1.0.58" />
9999
<Manifest Include="$(ApplicationManifest)" />
100100
</ItemGroup>
101101

SecureFolderFS.WinUI/WindowViews/MainWindow.xaml.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ private void EnsureEarlyWindow()
6363
{
6464
this.ExtendsContentIntoTitleBar = true;
6565
SetTitleBar(HostPage.CustomTitleBar);
66-
//HostPage.CustomTitleBar.Margin = new Thickness(0, 0, 138, 0); // Don't cover up Window buttons
6766
}
6867

6968
// Set mica material

0 commit comments

Comments
 (0)