Skip to content

Commit 030198d

Browse files
authored
Code Quality: Files.App/Helpers - convert into constant. (#15090)
1 parent eb60923 commit 030198d

File tree

4 files changed

+26
-25
lines changed

4 files changed

+26
-25
lines changed

src/Files.App/Helpers/Environment/SoftwareHelpers.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,22 @@ namespace Files.App.Helpers
88
{
99
internal static class SoftwareHelpers
1010
{
11+
private const string UninstallRegistryKey = @"Software\Microsoft\Windows\CurrentVersion\Uninstall";
12+
private const string VsRegistryKey = @"SOFTWARE\Microsoft\VisualStudio";
13+
14+
private const string VsCodeName = "Microsoft Visual Studio Code";
15+
16+
1117
public static bool IsVSCodeInstalled()
1218
{
13-
string registryKey = @"Software\Microsoft\Windows\CurrentVersion\Uninstall";
14-
string vsCodeName = "Microsoft Visual Studio Code";
15-
1619
return
17-
ContainsName(Registry.CurrentUser.OpenSubKey(registryKey), vsCodeName) ||
18-
ContainsName(Registry.LocalMachine.OpenSubKey(registryKey), vsCodeName);
20+
ContainsName(Registry.CurrentUser.OpenSubKey(UninstallRegistryKey), VsCodeName) ||
21+
ContainsName(Registry.LocalMachine.OpenSubKey(UninstallRegistryKey), VsCodeName);
1922
}
2023

2124
public static bool IsVSInstalled()
2225
{
23-
string registryKey = @"SOFTWARE\Microsoft\VisualStudio";
24-
25-
var key = Registry.LocalMachine.OpenSubKey(registryKey);
26+
var key = Registry.LocalMachine.OpenSubKey(VsRegistryKey);
2627
if (key is null)
2728
return false;
2829

src/Files.App/Helpers/NaturalStringComparer.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ namespace Files.App.Helpers
99
{
1010
internal static class SafeNativeMethods
1111
{
12-
public static readonly Int32 NORM_IGNORECASE = 0x00000001;
13-
public static readonly Int32 NORM_IGNORENONSPACE = 0x00000002;
14-
public static readonly Int32 NORM_IGNORESYMBOLS = 0x00000004;
15-
public static readonly Int32 LINGUISTIC_IGNORECASE = 0x00000010;
16-
public static readonly Int32 LINGUISTIC_IGNOREDIACRITIC = 0x00000020;
17-
public static readonly Int32 NORM_IGNOREKANATYPE = 0x00010000;
18-
public static readonly Int32 NORM_IGNOREWIDTH = 0x00020000;
19-
public static readonly Int32 NORM_LINGUISTIC_CASING = 0x08000000;
20-
public static readonly Int32 SORT_STRINGSORT = 0x00001000;
21-
public static readonly Int32 SORT_DIGITSASNUMBERS = 0x00000008;
12+
public const Int32 NORM_IGNORECASE = 0x00000001;
13+
public const Int32 NORM_IGNORENONSPACE = 0x00000002;
14+
public const Int32 NORM_IGNORESYMBOLS = 0x00000004;
15+
public const Int32 LINGUISTIC_IGNORECASE = 0x00000010;
16+
public const Int32 LINGUISTIC_IGNOREDIACRITIC = 0x00000020;
17+
public const Int32 NORM_IGNOREKANATYPE = 0x00010000;
18+
public const Int32 NORM_IGNOREWIDTH = 0x00020000;
19+
public const Int32 NORM_LINGUISTIC_CASING = 0x08000000;
20+
public const Int32 SORT_STRINGSORT = 0x00001000;
21+
public const Int32 SORT_DIGITSASNUMBERS = 0x00000008;
2222

23-
public static readonly String LOCALE_NAME_USER_DEFAULT = null;
24-
public static readonly String LOCALE_NAME_INVARIANT = String.Empty;
25-
public static readonly String LOCALE_NAME_SYSTEM_DEFAULT = "!sys-default-locale";
23+
public const String LOCALE_NAME_USER_DEFAULT = null;
24+
public const String LOCALE_NAME_INVARIANT = "";
25+
public const String LOCALE_NAME_SYSTEM_DEFAULT = "!sys-default-locale";
2626

2727
[DllImport("api-ms-win-core-string-l1-1-0.dll", CharSet = CharSet.Unicode)]
2828
public static extern Int32 CompareStringEx(

src/Files.App/Helpers/WMI/ManagementEventWatcher.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ internal enum CimWatcherStatus
4040
private CimSession _cimSession;
4141
private CimAsyncMultipleResults<CimSubscriptionResult> _cimObservable;
4242
private IDisposable _subscription;
43-
internal static readonly string DefaultNameSpace = @"root\cimv2";
44-
internal static readonly string DefaultQueryDialect = "WQL";
43+
internal const string DefaultNameSpace = @"root\cimv2";
44+
internal const string DefaultQueryDialect = "WQL";
4545

4646
/// <summary>
4747
/// Initializes a new instance of the <see cref="ManagementEventWatcher" /> class.

src/Files.App/Helpers/Win32/Win32Helper.Storage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public static string ExtractStringFromDLL(string file, int number)
228228
public static byte[]? GetIconOverlay(string path, bool isDirectory)
229229
{
230230
var shFileInfo = new Shell32.SHFILEINFO();
231-
var flags = Shell32.SHGFI.SHGFI_OVERLAYINDEX | Shell32.SHGFI.SHGFI_ICON | Shell32.SHGFI.SHGFI_SYSICONINDEX | Shell32.SHGFI.SHGFI_ICONLOCATION;
231+
const Shell32.SHGFI flags = Shell32.SHGFI.SHGFI_OVERLAYINDEX | Shell32.SHGFI.SHGFI_ICON | Shell32.SHGFI.SHGFI_SYSICONINDEX | Shell32.SHGFI.SHGFI_ICONLOCATION;
232232
byte[]? overlayData = null;
233233

234234
try
@@ -326,7 +326,7 @@ public static string ExtractStringFromDLL(string file, int number)
326326
else
327327
{
328328
var shfi = new Shell32.SHFILEINFO();
329-
var flags = Shell32.SHGFI.SHGFI_OVERLAYINDEX | Shell32.SHGFI.SHGFI_ICON | Shell32.SHGFI.SHGFI_SYSICONINDEX | Shell32.SHGFI.SHGFI_ICONLOCATION | Shell32.SHGFI.SHGFI_USEFILEATTRIBUTES;
329+
const Shell32.SHGFI flags = Shell32.SHGFI.SHGFI_OVERLAYINDEX | Shell32.SHGFI.SHGFI_ICON | Shell32.SHGFI.SHGFI_SYSICONINDEX | Shell32.SHGFI.SHGFI_ICONLOCATION | Shell32.SHGFI.SHGFI_USEFILEATTRIBUTES;
330330

331331
// Cannot access file, use file attributes
332332
var useFileAttibutes = iconData is null;

0 commit comments

Comments
 (0)