Skip to content

Commit a61e2c8

Browse files
**refactor: add XML docs, improve exception handling and archive extraction**
- Added comprehensive XML documentation to `GameFileParser`, `ArchiveService`, `UpdateService`, `FileItem`, and new `IExternalProcessService`. - Standardized exception rethrow using `ExceptionDispatchInfo.Capture().Throw()` in parsers. - Refactored archive extraction with `ExtractArchiveWithFallback` and `ExtractArchiveEntries` to eliminate duplication. - Switched to shared `SocketsHttpHandler` in `BugReportService` and `UpdateService` for connection pooling. - Updated `FileItem` property setters with early returns and minor cleanups.
1 parent 33675b6 commit a61e2c8

18 files changed

Lines changed: 1177 additions & 466 deletions

BatchConvertToCHD/AboutWindow.xaml.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@
55

66
namespace BatchConvertToCHD;
77

8+
/// <summary>
9+
/// About window displaying application version and information.
10+
/// </summary>
811
public partial class AboutWindow
912
{
13+
/// <summary>
14+
/// Initializes a new instance of the <see cref="AboutWindow"/> class.
15+
/// </summary>
1016
public AboutWindow()
1117
{
1218
InitializeComponent();

BatchConvertToCHD/App.xaml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -306,23 +306,6 @@
306306
</Setter>
307307
</Style>
308308

309-
<!-- Modern Log TextBox Style -->
310-
<Style x:Key="ModernLogTextBox" TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
311-
<Setter Property="FontFamily" Value="Consolas"/>
312-
<Setter Property="FontSize" Value="12"/>
313-
<Setter Property="Background" Value="{StaticResource TerminalBackgroundBrush}"/>
314-
<Setter Property="Foreground" Value="{StaticResource TerminalForegroundBrush}"/>
315-
<Setter Property="BorderThickness" Value="0"/>
316-
<Setter Property="Padding" Value="10"/>
317-
<Setter Property="AcceptsReturn" Value="True"/>
318-
<Setter Property="VerticalScrollBarVisibility" Value="Auto"/>
319-
<Setter Property="HorizontalScrollBarVisibility" Value="Auto"/>
320-
<Setter Property="IsReadOnly" Value="True"/>
321-
<Setter Property="TextAlignment" Value="Left"/>
322-
<Setter Property="TextWrapping" Value="NoWrap"/>
323-
<Setter Property="CaretBrush" Value="{StaticResource TerminalForegroundBrush}"/>
324-
</Style>
325-
326309
<!-- Default StatusBar Style -->
327310
<Style TargetType="StatusBar">
328311
<Setter Property="Background" Value="{StaticResource StatusBarBackgroundBrush}"/>

BatchConvertToCHD/App.xaml.cs

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

66
namespace BatchConvertToCHD;
77

8+
/// <summary>
9+
/// Application class for BatchConvertToCHD. Handles startup, exception handling, and service initialization.
10+
/// </summary>
811
public partial class App : IDisposable
912
{
1013
private BugReportService? _bugReportService;
@@ -15,6 +18,10 @@ public partial class App : IDisposable
1518
/// </summary>
1619
public static BugReportService? SharedBugReportService { get; private set; }
1720

21+
/// <summary>
22+
/// Initializes a new instance of the <see cref="App"/> class.
23+
/// Sets up services, exception handling, and event handlers.
24+
/// </summary>
1825
public App()
1926
{
2027
// Initialize services
@@ -95,12 +102,9 @@ private static void DeleteOldDllFiles()
95102

96103
private void App_Exit(object sender, ExitEventArgs e)
97104
{
98-
// Dispose services and clear references to prevent double disposal
99-
_bugReportService?.Dispose();
105+
// Clear references (HttpClient instances are static and reused across the app lifetime)
100106
_bugReportService = null;
101107
SharedBugReportService = null;
102-
103-
_statsService?.Dispose();
104108
_statsService = null;
105109

106110
// Unregister static event handlers to prevent memory leaks
@@ -152,12 +156,9 @@ private void ReportException(Exception exception, string source)
152156
public void Dispose()
153157
{
154158
// Cleanup is primarily handled in App_Exit. This method provides a safety net
155-
// for explicit disposal scenarios and prevents double disposal.
156-
_bugReportService?.Dispose();
159+
// for explicit disposal scenarios. HttpClient instances are static and reused.
157160
_bugReportService = null;
158161
SharedBugReportService = null;
159-
160-
_statsService?.Dispose();
161162
_statsService = null;
162163

163164
// Unregister static event handlers to prevent them from firing after disposal

BatchConvertToCHD/MainWindow.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
<StackPanel>
102102
<CheckBox x:Name="SearchSubfoldersConversionCheckBox" Content="Search subfolders (recursive search)" Margin="0,2" HorizontalAlignment="Left" ToolTip="Recursively search for files in all subfolders"
103103
Checked="SearchSubfoldersCheckBox_Changed" Unchecked="SearchSubfoldersCheckBox_Changed" />
104-
<CheckBox x:Name="DeleteOriginalsCheckBox" Content="Delete originals after a successfull conversion" Margin="0,2" HorizontalAlignment="Left" VerticalAlignment="Top" ToolTip="Automatically delete source files once they are successfully converted to CHD" />
104+
<CheckBox x:Name="DeleteOriginalsCheckBox" Content="Delete originals after a successful conversion" Margin="0,2" HorizontalAlignment="Left" VerticalAlignment="Top" ToolTip="Automatically delete source files once they are successfully converted to CHD" />
105105
<CheckBox x:Name="ProcessSmallerFirstCheckBox" Content="Process smaller files first" Margin="0,2" HorizontalAlignment="Left" ToolTip="Sort files by size and process the smallest ones first" />
106106
<StackPanel Orientation="Horizontal" Margin="0,2">
107107
<CheckBox x:Name="ForceCreateCdCheckBox" Content="Force CD" Margin="0,0,10,0" Checked="ForceCreateCdCheckBox_Checked" ToolTip="Force CHDMAN to use the 'createcd' command" />
@@ -238,7 +238,7 @@
238238
<StackPanel>
239239
<CheckBox x:Name="SearchSubfoldersExtractionCheckBox" Content="Search subfolders (recursive search)" Margin="0,2" HorizontalAlignment="Left" ToolTip="Recursively search for files in all subfolders"
240240
Checked="SearchSubfoldersCheckBox_Changed" Unchecked="SearchSubfoldersCheckBox_Changed" />
241-
<CheckBox x:Name="DeleteOriginalChdCheckBox" Content="Delete original CHD after a successfull extraction" Margin="0,2" HorizontalAlignment="Left" VerticalAlignment="Top" ToolTip="Delete original CHD after a successfull extraction" />
241+
<CheckBox x:Name="DeleteOriginalChdCheckBox" Content="Delete original CHD after a successful extraction" Margin="0,2" HorizontalAlignment="Left" VerticalAlignment="Top" ToolTip="Delete original CHD after a successfull extraction" />
242242
</StackPanel>
243243
</GroupBox>
244244
</Grid>

0 commit comments

Comments
 (0)