Skip to content

Commit e216aec

Browse files
committed
chore: reformat
1 parent 4bcf752 commit e216aec

8 files changed

Lines changed: 85 additions & 76 deletions

File tree

src/SVNPathCopy.Configuration/Converters/Converters.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
109109
return Visibility.Collapsed;
110110
}
111111

112-
foreach (var value in values)
112+
foreach (object value in values)
113113
{
114114
if (value is bool boolValue && !boolValue)
115115
{
@@ -123,4 +123,3 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
123123
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) =>
124124
throw new NotImplementedException();
125125
}
126-

src/SVNPathCopy.Configuration/MainWindow.xaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,12 @@
151151
</TextBlock>
152152
</StackPanel>
153153

154-
<TextBlock Text="Install the shell extension to enable context menu items in Windows Explorer. Requires administrator privileges."
155-
FontSize="12"
156-
Foreground="{StaticResource TextSecondaryBrush}"
157-
TextWrapping="Wrap"
158-
Margin="0,0,0,8" />
154+
<TextBlock
155+
Text="Install the shell extension to enable context menu items in Windows Explorer. Requires administrator privileges."
156+
FontSize="12"
157+
Foreground="{StaticResource TextSecondaryBrush}"
158+
TextWrapping="Wrap"
159+
Margin="0,0,0,8" />
159160

160161
<TextBlock FontSize="11"
161162
Foreground="{StaticResource TextSecondaryBrush}"
@@ -180,7 +181,8 @@
180181
IsEnabled="{Binding IsProcessing, Converter={StaticResource InverseBoolConverter}}">
181182
<Button.Visibility>
182183
<MultiBinding Converter="{StaticResource MultiBoolToVisibilityConverter}">
183-
<Binding Path="IsShellExtensionRegistered" Converter="{StaticResource InverseBoolConverter}" />
184+
<Binding Path="IsShellExtensionRegistered"
185+
Converter="{StaticResource InverseBoolConverter}" />
184186
<Binding Path="IsProcessing" Converter="{StaticResource InverseBoolConverter}" />
185187
</MultiBinding>
186188
</Button.Visibility>

src/SVNPathCopy.Configuration/SVNPathCopy.Configuration.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
</ItemGroup>
2828

2929
<ItemGroup>
30-
<Resource Include="Resources\SVNPathCopy-Icon.ico" />
30+
<Resource Include="Resources\SVNPathCopy-Icon.ico"/>
3131
</ItemGroup>
3232

3333
</Project>

src/SVNPathCopy.Configuration/ViewModels/MainViewModel.cs

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
using System.ComponentModel;
2+
using System.IO;
13
using CommunityToolkit.Mvvm.ComponentModel;
24
using CommunityToolkit.Mvvm.Input;
35
using Microsoft.Win32;
46
using SVNPathCopy.Core.Interfaces;
57
using SVNPathCopy.Core.Models;
68
using SVNPathCopy.Core.Services;
7-
using System.IO;
8-
using System.Threading.Tasks;
99

1010
namespace SVNPathCopy.Configuration.ViewModels;
1111

@@ -17,26 +17,26 @@ public partial class MainViewModel : ObservableObject
1717
private static readonly Guid _shellExtensionClsid = new("ED4DD0F3-E4E3-4F8A-AD97-7B76FC3E0965");
1818
private readonly IConfigurationService _configService;
1919
private readonly IShellExtensionService _shellExtensionService;
20-
private bool _suppressAutosave;
2120

2221
[ObservableProperty] [NotifyPropertyChangedFor(nameof(StatusText))] [NotifyPropertyChangedFor(nameof(IsEnabled))]
2322
private bool _extensionEnabled = true;
2423

24+
[ObservableProperty] private bool _isProcessing;
25+
2526
[ObservableProperty] private bool _isShellExtensionRegistered;
2627

28+
[ObservableProperty] private bool _isStatusError;
29+
2730
[ObservableProperty] private UrlEncodingStyle _selectedEncodingStyle = UrlEncodingStyle.Path;
2831

32+
[ObservableProperty] private string _shellExtensionPath = string.Empty;
33+
2934
[ObservableProperty] private bool _showCopyWithoutRevision = true;
3035

3136
[ObservableProperty] private bool _showCopyWithRevision = true;
3237

3338
[ObservableProperty] private string _statusMessage = string.Empty;
34-
35-
[ObservableProperty] private bool _isStatusError;
36-
37-
[ObservableProperty] private bool _isProcessing;
38-
39-
[ObservableProperty] private string _shellExtensionPath = string.Empty;
39+
private bool _suppressAutosave;
4040

4141
/// <summary>
4242
/// Initializes a new instance of the <see cref="MainViewModel" /> class.
@@ -203,10 +203,7 @@ private async Task InstallShellExtension()
203203
StatusMessage = "Installing shell extension... Please accept the UAC prompt if it appears.";
204204
IsStatusError = false;
205205

206-
await Task.Run(() =>
207-
{
208-
_shellExtensionService.Register();
209-
});
206+
await Task.Run(() => { _shellExtensionService.Register(); });
210207

211208
// Small delay to allow registry to update
212209
await Task.Delay(500);
@@ -217,15 +214,17 @@ await Task.Run(() =>
217214
if (IsShellExtensionRegistered)
218215
{
219216
IsStatusError = false;
220-
StatusMessage = "✓ Shell extension installed successfully. Please restart Windows Explorer to see the context menu (right-click taskbar → Task Manager → Find 'Windows Explorer' → Restart).";
217+
StatusMessage =
218+
"✓ Shell extension installed successfully. Please restart Windows Explorer to see the context menu (right-click taskbar → Task Manager → Find 'Windows Explorer' → Restart).";
221219
}
222220
else
223221
{
224222
IsStatusError = true;
225-
StatusMessage = "⚠ Installation command completed but shell extension is not showing as registered. Try clicking 'Refresh Status'.";
223+
StatusMessage =
224+
"⚠ Installation command completed but shell extension is not showing as registered. Try clicking 'Refresh Status'.";
226225
}
227226
}
228-
catch (System.ComponentModel.Win32Exception ex) when (ex.NativeErrorCode == 1223)
227+
catch (Win32Exception ex) when (ex.NativeErrorCode == 1223)
229228
{
230229
// ERROR_CANCELLED - User cancelled the UAC prompt
231230
IsStatusError = true;
@@ -266,10 +265,7 @@ private async Task UninstallShellExtension()
266265
StatusMessage = "Uninstalling shell extension... Please accept the UAC prompt if it appears.";
267266
IsStatusError = false;
268267

269-
await Task.Run(() =>
270-
{
271-
_shellExtensionService.Unregister();
272-
});
268+
await Task.Run(() => { _shellExtensionService.Unregister(); });
273269

274270
// Small delay to allow registry to update
275271
await Task.Delay(500);
@@ -280,19 +276,22 @@ await Task.Run(() =>
280276
if (!IsShellExtensionRegistered)
281277
{
282278
IsStatusError = false;
283-
StatusMessage = "✓ Shell extension uninstalled successfully. Please restart Windows Explorer to remove the context menu (right-click taskbar → Task Manager → Find 'Windows Explorer' → Restart).";
279+
StatusMessage =
280+
"✓ Shell extension uninstalled successfully. Please restart Windows Explorer to remove the context menu (right-click taskbar → Task Manager → Find 'Windows Explorer' → Restart).";
284281
}
285282
else
286283
{
287284
IsStatusError = true;
288-
StatusMessage = "⚠ Uninstallation command completed but shell extension is still showing as registered. Try clicking 'Refresh Status'.";
285+
StatusMessage =
286+
"⚠ Uninstallation command completed but shell extension is still showing as registered. Try clicking 'Refresh Status'.";
289287
}
290288
}
291-
catch (System.ComponentModel.Win32Exception ex) when (ex.NativeErrorCode == 1223)
289+
catch (Win32Exception ex) when (ex.NativeErrorCode == 1223)
292290
{
293291
// ERROR_CANCELLED - User cancelled the UAC prompt
294292
IsStatusError = true;
295-
StatusMessage = "Uninstallation cancelled. You must accept the UAC prompt to uninstall the shell extension.";
293+
StatusMessage =
294+
"Uninstallation cancelled. You must accept the UAC prompt to uninstall the shell extension.";
296295
}
297296
catch (FileNotFoundException ex)
298297
{

src/SVNPathCopy.Core/Services/ShellExtensionService.cs

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Diagnostics;
2-
using System.IO;
32
using Microsoft.Win32;
43
using SVNPathCopy.Core.Interfaces;
54

@@ -13,22 +12,20 @@ public class ShellExtensionService : IShellExtensionService
1312
private static readonly Guid _shellExtensionClsid = new("ED4DD0F3-E4E3-4F8A-AD97-7B76FC3E0965");
1413

1514
/// <inheritdoc />
16-
public bool IsRegistered()
17-
{
18-
return IsShellExtensionComRegistered(_shellExtensionClsid);
19-
}
15+
public bool IsRegistered() => IsShellExtensionComRegistered(_shellExtensionClsid);
2016

2117
/// <inheritdoc />
2218
public bool Register()
2319
{
2420
string? assemblyPath = GetAssemblyPath();
2521
if (string.IsNullOrEmpty(assemblyPath) || !File.Exists(assemblyPath))
2622
{
27-
throw new FileNotFoundException($"Shell extension assembly not found. Searched locations around: {AppContext.BaseDirectory}");
23+
throw new FileNotFoundException(
24+
$"Shell extension assembly not found. Searched locations around: {AppContext.BaseDirectory}");
2825
}
2926

3027
// Use regasm to register the shell extension
31-
var regasmPath = GetRegAsmPath();
28+
string? regasmPath = GetRegAsmPath();
3229
if (string.IsNullOrEmpty(regasmPath))
3330
{
3431
throw new FileNotFoundException("RegAsm.exe not found. .NET Framework 4.x must be installed.");
@@ -54,7 +51,8 @@ public bool Register()
5451

5552
if (process.ExitCode != 0)
5653
{
57-
throw new InvalidOperationException($"RegAsm.exe failed with exit code {process.ExitCode}. Make sure you accepted the UAC prompt and have administrator privileges.");
54+
throw new InvalidOperationException(
55+
$"RegAsm.exe failed with exit code {process.ExitCode}. Make sure you accepted the UAC prompt and have administrator privileges.");
5856
}
5957

6058
return true;
@@ -66,11 +64,12 @@ public bool Unregister()
6664
string? assemblyPath = GetAssemblyPath();
6765
if (string.IsNullOrEmpty(assemblyPath) || !File.Exists(assemblyPath))
6866
{
69-
throw new FileNotFoundException($"Shell extension assembly not found. Searched locations around: {AppContext.BaseDirectory}");
67+
throw new FileNotFoundException(
68+
$"Shell extension assembly not found. Searched locations around: {AppContext.BaseDirectory}");
7069
}
7170

7271
// Use regasm to unregister the shell extension
73-
var regasmPath = GetRegAsmPath();
72+
string? regasmPath = GetRegAsmPath();
7473
if (string.IsNullOrEmpty(regasmPath))
7574
{
7675
throw new FileNotFoundException("RegAsm.exe not found. .NET Framework 4.x must be installed.");
@@ -96,7 +95,8 @@ public bool Unregister()
9695

9796
if (process.ExitCode != 0)
9897
{
99-
throw new InvalidOperationException($"RegAsm.exe failed with exit code {process.ExitCode}. Make sure you accepted the UAC prompt and have administrator privileges.");
98+
throw new InvalidOperationException(
99+
$"RegAsm.exe failed with exit code {process.ExitCode}. Make sure you accepted the UAC prompt and have administrator privileges.");
100100
}
101101

102102
return true;
@@ -106,40 +106,48 @@ public bool Unregister()
106106
public string? GetAssemblyPath()
107107
{
108108
// Try to find the shell extension DLL in common locations
109-
var baseDir = AppContext.BaseDirectory;
109+
string? baseDir = AppContext.BaseDirectory;
110110

111111
// BaseDir for Configuration app during development is typically:
112112
// SVNPathCopy\src\SVNPathCopy.Configuration\bin\Debug\net10.0-windows\win-x64\
113113
// We need to navigate to:
114114
// SVNPathCopy\src\SVNPathCopy.ShellExtension\bin\x64\Debug\net48\
115115

116-
var candidatePaths = new[]
116+
string[] candidatePaths = new[]
117117
{
118118
// Same directory (for installed/packaged version)
119119
Path.Combine(baseDir, "SVNPathCopy.ShellExtension.dll"),
120120

121121
// Development paths from Configuration output directory
122122
// From: src\SVNPathCopy.Configuration\bin\Debug\net10.0-windows\win-x64\
123123
// To: src\SVNPathCopy.ShellExtension\bin\x64\Debug\net48\
124-
Path.Combine(baseDir, "..", "..", "..", "..", "..", "SVNPathCopy.ShellExtension", "bin", "x64", "Debug", "net48", "SVNPathCopy.ShellExtension.dll"),
125-
Path.Combine(baseDir, "..", "..", "..", "..", "..", "SVNPathCopy.ShellExtension", "bin", "x64", "Release", "net48", "SVNPathCopy.ShellExtension.dll"),
126-
Path.Combine(baseDir, "..", "..", "..", "..", "..", "SVNPathCopy.ShellExtension", "bin", "Debug", "net48", "SVNPathCopy.ShellExtension.dll"),
127-
Path.Combine(baseDir, "..", "..", "..", "..", "..", "SVNPathCopy.ShellExtension", "bin", "Release", "net48", "SVNPathCopy.ShellExtension.dll"),
124+
Path.Combine(baseDir, "..", "..", "..", "..", "..", "SVNPathCopy.ShellExtension", "bin", "x64", "Debug",
125+
"net48", "SVNPathCopy.ShellExtension.dll"),
126+
Path.Combine(baseDir, "..", "..", "..", "..", "..", "SVNPathCopy.ShellExtension", "bin", "x64", "Release",
127+
"net48", "SVNPathCopy.ShellExtension.dll"),
128+
Path.Combine(baseDir, "..", "..", "..", "..", "..", "SVNPathCopy.ShellExtension", "bin", "Debug", "net48",
129+
"SVNPathCopy.ShellExtension.dll"),
130+
Path.Combine(baseDir, "..", "..", "..", "..", "..", "SVNPathCopy.ShellExtension", "bin", "Release", "net48",
131+
"SVNPathCopy.ShellExtension.dll"),
128132

129133
// Alternative paths (in case of different build output structure)
130134
Path.Combine(baseDir, "..", "SVNPathCopy.ShellExtension.dll"),
131135
Path.Combine(baseDir, "..", "..", "SVNPathCopy.ShellExtension.dll"),
132-
Path.Combine(baseDir, "..", "..", "..", "SVNPathCopy.ShellExtension", "bin", "x64", "Debug", "net48", "SVNPathCopy.ShellExtension.dll"),
133-
Path.Combine(baseDir, "..", "..", "..", "SVNPathCopy.ShellExtension", "bin", "x64", "Release", "net48", "SVNPathCopy.ShellExtension.dll"),
134-
Path.Combine(baseDir, "..", "..", "..", "SVNPathCopy.ShellExtension", "bin", "Debug", "net48", "SVNPathCopy.ShellExtension.dll"),
135-
Path.Combine(baseDir, "..", "..", "..", "SVNPathCopy.ShellExtension", "bin", "Release", "net48", "SVNPathCopy.ShellExtension.dll")
136+
Path.Combine(baseDir, "..", "..", "..", "SVNPathCopy.ShellExtension", "bin", "x64", "Debug", "net48",
137+
"SVNPathCopy.ShellExtension.dll"),
138+
Path.Combine(baseDir, "..", "..", "..", "SVNPathCopy.ShellExtension", "bin", "x64", "Release", "net48",
139+
"SVNPathCopy.ShellExtension.dll"),
140+
Path.Combine(baseDir, "..", "..", "..", "SVNPathCopy.ShellExtension", "bin", "Debug", "net48",
141+
"SVNPathCopy.ShellExtension.dll"),
142+
Path.Combine(baseDir, "..", "..", "..", "SVNPathCopy.ShellExtension", "bin", "Release", "net48",
143+
"SVNPathCopy.ShellExtension.dll")
136144
};
137145

138-
foreach (var path in candidatePaths)
146+
foreach (string path in candidatePaths)
139147
{
140148
try
141149
{
142-
var fullPath = Path.GetFullPath(path);
150+
string fullPath = Path.GetFullPath(path);
143151
if (File.Exists(fullPath))
144152
{
145153
return fullPath;
@@ -152,16 +160,16 @@ public bool Unregister()
152160
}
153161

154162
// Check in Program Files (for installed version)
155-
var programFiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
156-
var installedPaths = new[]
163+
string programFiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
164+
string[] installedPaths = new[]
157165
{
158166
// Installed location: "SVN Path Copy\ShellExtension\" subdirectory
159167
Path.Combine(programFiles, "SVN Path Copy", "ShellExtension", "SVNPathCopy.ShellExtension.dll"),
160168
// Fallback: same directory as config app
161-
Path.Combine(programFiles, "SVN Path Copy", "SVNPathCopy.ShellExtension.dll"),
169+
Path.Combine(programFiles, "SVN Path Copy", "SVNPathCopy.ShellExtension.dll")
162170
};
163-
164-
foreach (var instPath in installedPaths)
171+
172+
foreach (string instPath in installedPaths)
165173
{
166174
if (File.Exists(instPath))
167175
{
@@ -175,14 +183,14 @@ public bool Unregister()
175183
private static string? GetRegAsmPath()
176184
{
177185
// Try to find regasm.exe for .NET Framework
178-
var windowsDir = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
179-
var netFrameworkPaths = new[]
186+
string windowsDir = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
187+
string[] netFrameworkPaths = new[]
180188
{
181189
Path.Combine(windowsDir, @"Microsoft.NET\Framework64\v4.0.30319\regasm.exe"),
182190
Path.Combine(windowsDir, @"Microsoft.NET\Framework\v4.0.30319\regasm.exe")
183191
};
184192

185-
foreach (var path in netFrameworkPaths)
193+
foreach (string path in netFrameworkPaths)
186194
{
187195
if (File.Exists(path))
188196
{
@@ -227,4 +235,3 @@ private static bool RegistryKeyExists(RegistryHive hive, RegistryView view, stri
227235
}
228236
}
229237
}
230-

src/SVNPathCopy.Installer/Components.wxs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858
Target="[INSTALLFOLDER]SVNPathCopy.Configuration.exe"
5959
WorkingDirectory="INSTALLFOLDER"/>
6060
<!-- Remove shortcut on uninstall -->
61-
<RemoveFile Id="RemoveConfigurationShortcut"
62-
Name="SVN Path Copy Configuration.lnk"
61+
<RemoveFile Id="RemoveConfigurationShortcut"
62+
Name="SVN Path Copy Configuration.lnk"
6363
On="uninstall"
6464
Directory="ApplicationProgramsFolder"/>
6565
<!-- Remove the Start Menu folder on uninstall -->

src/SVNPathCopy.Installer/Package.wxs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,21 @@
4141
- Configuration App: .NET 10 Desktop Runtime (will prompt if missing)
4242
-->
4343

44-
<!--
44+
<!--
4545
Note: We do NOT close Explorer during uninstall because:
4646
1. It causes user disruption (desktop/taskbar disappear)
4747
2. Can trigger reboot prompts even with RebootPrompt="no"
4848
3. The DLL will be removed on next reboot if locked (PendingFileRenameOperations)
49-
49+
5050
Windows will automatically handle locked files via MoveFileEx with MOVEFILE_DELAY_UNTIL_REBOOT.
5151
-->
52-
52+
5353
<!-- Suppress reboot prompts - files will be removed on next natural restart if locked -->
5454
<Property Id="REBOOT" Value="ReallySuppress"/>
5555

5656
<!-- Features -->
57-
<Feature Id="ProductFeature" Title="SVN Path Copy" Level="1" Description="Installs the SVN Path Copy shell extension and configuration utility.">
57+
<Feature Id="ProductFeature" Title="SVN Path Copy" Level="1"
58+
Description="Installs the SVN Path Copy shell extension and configuration utility.">
5859
<ComponentGroupRef Id="ProductComponents"/>
5960
<ComponentGroupRef Id="ShellExtensionComponents"/>
6061
</Feature>

0 commit comments

Comments
 (0)