Skip to content

Code Quality: Files.App/Helpers - convert into constant. #15090

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/Files.App/Helpers/Environment/SoftwareHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@ namespace Files.App.Helpers
{
internal static class SoftwareHelpers
{
private const string UninstallRegistryKey = @"Software\Microsoft\Windows\CurrentVersion\Uninstall";
private const string VsRegistryKey = @"SOFTWARE\Microsoft\VisualStudio";

private const string VsCodeName = "Microsoft Visual Studio Code";


public static bool IsVSCodeInstalled()
{
string registryKey = @"Software\Microsoft\Windows\CurrentVersion\Uninstall";
string vsCodeName = "Microsoft Visual Studio Code";

return
ContainsName(Registry.CurrentUser.OpenSubKey(registryKey), vsCodeName) ||
ContainsName(Registry.LocalMachine.OpenSubKey(registryKey), vsCodeName);
ContainsName(Registry.CurrentUser.OpenSubKey(UninstallRegistryKey), VsCodeName) ||
ContainsName(Registry.LocalMachine.OpenSubKey(UninstallRegistryKey), VsCodeName);
}

public static bool IsVSInstalled()
{
string registryKey = @"SOFTWARE\Microsoft\VisualStudio";

var key = Registry.LocalMachine.OpenSubKey(registryKey);
var key = Registry.LocalMachine.OpenSubKey(VsRegistryKey);
if (key is null)
return false;

Expand Down
26 changes: 13 additions & 13 deletions src/Files.App/Helpers/NaturalStringComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ namespace Files.App.Helpers
{
internal static class SafeNativeMethods
{
public static readonly Int32 NORM_IGNORECASE = 0x00000001;
public static readonly Int32 NORM_IGNORENONSPACE = 0x00000002;
public static readonly Int32 NORM_IGNORESYMBOLS = 0x00000004;
public static readonly Int32 LINGUISTIC_IGNORECASE = 0x00000010;
public static readonly Int32 LINGUISTIC_IGNOREDIACRITIC = 0x00000020;
public static readonly Int32 NORM_IGNOREKANATYPE = 0x00010000;
public static readonly Int32 NORM_IGNOREWIDTH = 0x00020000;
public static readonly Int32 NORM_LINGUISTIC_CASING = 0x08000000;
public static readonly Int32 SORT_STRINGSORT = 0x00001000;
public static readonly Int32 SORT_DIGITSASNUMBERS = 0x00000008;
public const Int32 NORM_IGNORECASE = 0x00000001;
public const Int32 NORM_IGNORENONSPACE = 0x00000002;
public const Int32 NORM_IGNORESYMBOLS = 0x00000004;
public const Int32 LINGUISTIC_IGNORECASE = 0x00000010;
public const Int32 LINGUISTIC_IGNOREDIACRITIC = 0x00000020;
public const Int32 NORM_IGNOREKANATYPE = 0x00010000;
public const Int32 NORM_IGNOREWIDTH = 0x00020000;
public const Int32 NORM_LINGUISTIC_CASING = 0x08000000;
public const Int32 SORT_STRINGSORT = 0x00001000;
public const Int32 SORT_DIGITSASNUMBERS = 0x00000008;

public static readonly String LOCALE_NAME_USER_DEFAULT = null;
public static readonly String LOCALE_NAME_INVARIANT = String.Empty;
public static readonly String LOCALE_NAME_SYSTEM_DEFAULT = "!sys-default-locale";
public const String LOCALE_NAME_USER_DEFAULT = null;
public const String LOCALE_NAME_INVARIANT = "";
public const String LOCALE_NAME_SYSTEM_DEFAULT = "!sys-default-locale";

[DllImport("api-ms-win-core-string-l1-1-0.dll", CharSet = CharSet.Unicode)]
public static extern Int32 CompareStringEx(
Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Helpers/WMI/ManagementEventWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ internal enum CimWatcherStatus
private CimSession _cimSession;
private CimAsyncMultipleResults<CimSubscriptionResult> _cimObservable;
private IDisposable _subscription;
internal static readonly string DefaultNameSpace = @"root\cimv2";
internal static readonly string DefaultQueryDialect = "WQL";
internal const string DefaultNameSpace = @"root\cimv2";
internal const string DefaultQueryDialect = "WQL";

/// <summary>
/// Initializes a new instance of the <see cref="ManagementEventWatcher" /> class.
Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Helpers/Win32/Win32Helper.Storage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public static string ExtractStringFromDLL(string file, int number)
public static byte[]? GetIconOverlay(string path, bool isDirectory)
{
var shFileInfo = new Shell32.SHFILEINFO();
var flags = Shell32.SHGFI.SHGFI_OVERLAYINDEX | Shell32.SHGFI.SHGFI_ICON | Shell32.SHGFI.SHGFI_SYSICONINDEX | Shell32.SHGFI.SHGFI_ICONLOCATION;
const Shell32.SHGFI flags = Shell32.SHGFI.SHGFI_OVERLAYINDEX | Shell32.SHGFI.SHGFI_ICON | Shell32.SHGFI.SHGFI_SYSICONINDEX | Shell32.SHGFI.SHGFI_ICONLOCATION;
byte[]? overlayData = null;

try
Expand Down Expand Up @@ -326,7 +326,7 @@ public static string ExtractStringFromDLL(string file, int number)
else
{
var shfi = new Shell32.SHFILEINFO();
var flags = Shell32.SHGFI.SHGFI_OVERLAYINDEX | Shell32.SHGFI.SHGFI_ICON | Shell32.SHGFI.SHGFI_SYSICONINDEX | Shell32.SHGFI.SHGFI_ICONLOCATION | Shell32.SHGFI.SHGFI_USEFILEATTRIBUTES;
const Shell32.SHGFI flags = Shell32.SHGFI.SHGFI_OVERLAYINDEX | Shell32.SHGFI.SHGFI_ICON | Shell32.SHGFI.SHGFI_SYSICONINDEX | Shell32.SHGFI.SHGFI_ICONLOCATION | Shell32.SHGFI.SHGFI_USEFILEATTRIBUTES;

// Cannot access file, use file attributes
var useFileAttibutes = iconData is null;
Expand Down