Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public bool IsExecutable

public Task ExecuteAsync()
{
if (GetFocusedElement() is SelectorItem item)
if (GetFocusedElement() is { } item)
item.IsSelected = !item.IsSelected;

return Task.CompletedTask;
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Actions/Content/Tags/OpenAllTaggedActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Files.App.Actions
{
sealed class OpenAllTaggedActions: ObservableObject, IAction
internal sealed class OpenAllTaggedActions: ObservableObject, IAction
{
private readonly IContentPageContext _pageContext;

Expand Down
Binary file modified src/Files.App/Assets/FilesOpenDialog/Files.App.Launcher.exe
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9f09add6084f2b30451d91864a573cc4cd0bf728a1df9bfc87fd1b7027487c60
fc811e6469b14b686119a9f8e0d78de7089b0ba3c8c0820a993b8f9f9f7c817f
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public object Convert(object value, Type targetType, object parameter, string la

public object ConvertBack(object value, Type targetType, object parameter, string language)
{
return (value is bool bl && bl) ? StorageDeleteOption.PermanentDelete : StorageDeleteOption.Default;
return value is true ? StorageDeleteOption.PermanentDelete : StorageDeleteOption.Default;
}
}
}
8 changes: 3 additions & 5 deletions src/Files.App/Converters/StringArrayToStringConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,21 @@ internal sealed class StringArrayToStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
var array = value as string[];

if (array is null || !(array is string[]))
if (value is not string[] array)
return string.Empty;

var str = new StringBuilder();
foreach (var i in array)
{
str.Append(string.Format("{0}; ", i));
str.Append($"{i}; ");
}

return str.ToString();
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
{
return (value as string).Split("; ");
return (value as string)?.Split("; ") ?? [];
}
}
}
2 changes: 1 addition & 1 deletion src/Files.App/Data/Commands/Manager/CommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public CommandManager()
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
public IEnumerator<IRichCommand> GetEnumerator() => commands.Values.GetEnumerator();

private static IDictionary<CommandCodes, IAction> CreateActions() => new Dictionary<CommandCodes, IAction>
private static Dictionary<CommandCodes, IAction> CreateActions() => new Dictionary<CommandCodes, IAction>
{
[CommandCodes.OpenHelp] = new OpenHelpAction(),
[CommandCodes.ToggleFullScreen] = new ToggleFullScreenAction(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal class ModifiableCommandManager : IModifiableCommandManager
{
private static readonly ICommandManager Commands = Ioc.Default.GetRequiredService<ICommandManager>();

private readonly IImmutableDictionary<CommandCodes, IRichCommand> ModifiableCommands;
private readonly ImmutableDictionary<CommandCodes, IRichCommand> ModifiableCommands;

public IRichCommand this[CommandCodes code] => ModifiableCommands.TryGetValue(code, out var command) ? command : None;

Expand All @@ -25,7 +25,7 @@ public ModifiableCommandManager()
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
public IEnumerator<IRichCommand> GetEnumerator() => ModifiableCommands.Values.GetEnumerator();

private static IDictionary<CommandCodes, IRichCommand> CreateModifiableCommands() => new Dictionary<CommandCodes, IRichCommand>
private static Dictionary<CommandCodes, IRichCommand> CreateModifiableCommands() => new Dictionary<CommandCodes, IRichCommand>
{
[CommandCodes.None] = new NoneCommand(),
[CommandCodes.PasteItem] = new ModifiableCommand(Commands.PasteItem, new() {
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Helpers/Application/AppLifecycleHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public static void SaveSessionTabs()

userSettingsService.GeneralSettingsService.LastSessionTabList = MainPageViewModel.AppInstances.DefaultIfEmpty().Select(tab =>
{
if (tab is not null && tab.NavigationParameter is not null)
if (tab?.NavigationParameter != null)
{
return tab.NavigationParameter.Serialize();
}
Expand Down
2 changes: 0 additions & 2 deletions src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ namespace Files.App.Helpers
{
public static class LayoutSizeKindHelper
{
private static ILayoutSettingsService LayoutSettingsService { get; } = Ioc.Default.GetRequiredService<ILayoutSettingsService>();

/// <summary>
/// Gets the desired height for items in the Details View
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions src/Files.App/Helpers/MenuFlyout/MenuFlyoutHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ namespace Files.App.Helpers
[Obsolete("Must not use this helper to generate menu flyout any longer.")]
public class MenuFlyoutHelper : DependencyObject
{
public interface IMenuFlyoutItemViewModel { }
public interface IMenuFlyoutItemViewModel;

public class MenuFlyoutSeparatorViewModel : IMenuFlyoutItemViewModel { }
public class MenuFlyoutSeparatorViewModel : IMenuFlyoutItemViewModel;

public class MenuFlyoutItemViewModel : IMenuFlyoutItemViewModel
{
Expand Down Expand Up @@ -123,7 +123,7 @@ private static void AddItems(IList<MenuFlyoutItemBase> menu, IEnumerable<IMenuFl
var mfsi = new MenuFlyoutSubItem
{
Text = svm.Text,
IsEnabled = svm.IsEnabled && svm.Items.Count > 0,
IsEnabled = svm is { IsEnabled: true, Items.Count: > 0 },
};
AddItems(mfsi.Items, svm.Items);
menu.Add(mfsi);
Expand Down
6 changes: 3 additions & 3 deletions src/Files.App/Helpers/ShareItemHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ async void Manager_DataRequested(DataTransferManager sender, DataRequestedEventA
return;
}
}
else if (item.PrimaryItemAttribute == StorageItemTypes.Folder && !item.IsArchive)
else if (item is { PrimaryItemAttribute: StorageItemTypes.Folder, IsArchive: false })
{
if (await StorageHelpers.ToStorageItem<BaseStorageFolder>(item.ItemPath) is BaseStorageFolder folder)
if (await StorageHelpers.ToStorageItem<BaseStorageFolder>(item.ItemPath) is { } folder)
items.Add(folder);
}
else
{
if (await StorageHelpers.ToStorageItem<BaseStorageFile>(item.ItemPath) is BaseStorageFile file)
if (await StorageHelpers.ToStorageItem<BaseStorageFile>(item.ItemPath) is { } file)
items.Add(file);
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/Files.App/Helpers/TypesConverter.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.

using System;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Files.App.Helpers
{
public class KnownTypesConverter
{
public JsonSerializerOptions Options { get; } = new JsonSerializerOptions();
public JsonSerializerOptions Options { get; } = new();

public KnownTypesConverter()
{
Expand Down
10 changes: 5 additions & 5 deletions src/Files.App/Helpers/UI/AppThemeResourcesHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ public static void LoadAppResources(this IResourcesService service, IAppearanceS

try
{
service.SetAppThemeBackgroundColor(ColorHelper.ToColor(appThemeBackgroundColor).FromWindowsColor());
service.SetAppThemeBackgroundColor(appThemeBackgroundColor.ToColor().FromWindowsColor());
}
catch
{
appearance.AppThemeBackgroundColor = "#00000000"; //migrate to new default
service.SetAppThemeBackgroundColor(ColorHelper.ToColor("#00000000").FromWindowsColor());
service.SetAppThemeBackgroundColor("#00000000".ToColor().FromWindowsColor());
}

if (!string.IsNullOrWhiteSpace(appThemeAddressBarBackgroundColor) && appThemeAddressBarBackgroundColor != "#00000000")
{
try
{
service.SetAppThemeAddressBarBackgroundColor(ColorHelper.ToColor(appThemeAddressBarBackgroundColor).FromWindowsColor());
service.SetAppThemeAddressBarBackgroundColor(appThemeAddressBarBackgroundColor.ToColor().FromWindowsColor());
}
catch
{
Expand All @@ -49,7 +49,7 @@ public static void LoadAppResources(this IResourcesService service, IAppearanceS
{
try
{
service.SetAppThemeSidebarBackgroundColor(ColorHelper.ToColor(appThemeSidebarBackgroundColor).FromWindowsColor());
service.SetAppThemeSidebarBackgroundColor(appThemeSidebarBackgroundColor.ToColor().FromWindowsColor());
}
catch
{
Expand All @@ -63,7 +63,7 @@ public static void LoadAppResources(this IResourcesService service, IAppearanceS
{
try
{
service.SetAppThemeFileAreaBackgroundColor(ColorHelper.ToColor(appThemeFileAreaBackgroundColor).FromWindowsColor());
service.SetAppThemeFileAreaBackgroundColor(appThemeFileAreaBackgroundColor.ToColor().FromWindowsColor());
}
catch
{
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Helpers/Xaml/DependencyObjectHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static T FindChild<T>(DependencyObject startNode) where T : DependencyObj
for (int i = 0; i < count; i++)
{
DependencyObject current = VisualTreeHelper.GetChild(startNode, i);
if (current.GetType().Equals(typeof(T)) || current.GetType().GetTypeInfo().IsSubclassOf(typeof(T)))
if (current.GetType() == typeof(T) || current.GetType().GetTypeInfo().IsSubclassOf(typeof(T)))
{
T asType = (T)current;
return asType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public override string ToLongLabel(DateTimeOffset offset)
if (offset.Year is <= 1601 or >= 9999)
return " ";

if (elapsed.TotalDays < 7 && elapsed.TotalSeconds >= 0)
if (elapsed is { TotalDays: < 7, TotalSeconds: >= 0 })
return $"{ToString(offset, "D")} {ToString(offset, "t")} ({ToShortLabel(offset)})";

return $"{ToString(offset, "D")} {ToString(offset, "t")}";
Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Services/FileExplorerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public Task OpenInFileExplorerAsync(ILocatableFolder folder, CancellationToken c
}

// WINUI3
private FileOpenPicker InitializeWithWindow(FileOpenPicker obj)
private static FileOpenPicker InitializeWithWindow(FileOpenPicker obj)
{
WinRT.Interop.InitializeWithWindow.Initialize(obj, MainWindow.Instance.WindowHandle);
return obj;
Expand All @@ -61,7 +61,7 @@ private FileOpenPicker InitializeWithWindow(FileOpenPicker obj)
}

// WINUI3
private FolderPicker InitializeWithWindow(FolderPicker obj)
private static FolderPicker InitializeWithWindow(FolderPicker obj)
{
WinRT.Interop.InitializeWithWindow.Initialize(obj, MainWindow.Instance.WindowHandle);

Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Services/JumpListService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private void AddFolder(string path, string group, JumpList instance)
}
else
{
var pinnedItemsCount = instance.Items.Where(x => x.GroupName == JumpListPinnedGroupHeader).Count();
var pinnedItemsCount = instance.Items.Count(x => x.GroupName == JumpListPinnedGroupHeader);
instance.Items.Insert(pinnedItemsCount, jumplistItem);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public async Task SwitchPreviewAsync(string path)
await DoPreviewAsync(path, pipeMessageSwitch);
}

private async Task DoPreviewAsync(string path, string message)
private static async Task DoPreviewAsync(string path, string message)
{
string pipeName = $"QuickLook.App.Pipe.{WindowsIdentity.GetCurrent().User?.Value}";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class SeerProProvider : IPreviewPopupProvider

private string? CurrentPath;

public async Task TogglePreviewPopupAsync(string path)
public Task TogglePreviewPopupAsync(string path)
{
HWND Window = User32.FindWindow("SeerWindowClass", null);
COPYDATASTRUCT data = new COPYDATASTRUCT();
Expand All @@ -30,6 +30,7 @@ public async Task TogglePreviewPopupAsync(string path)
User32.SendMessage(Window, (uint)User32.WindowMessage.WM_COPYDATA, 0, ref data);

CurrentPath = User32.IsWindowVisible(Window) ? path : null;
return Task.CompletedTask;
}

public async Task SwitchPreviewAsync(string path)
Expand All @@ -38,10 +39,10 @@ public async Task SwitchPreviewAsync(string path)
await TogglePreviewPopupAsync(path);
}

public async Task<bool> DetectAvailability()
public Task<bool> DetectAvailability()
{
var handle = User32.FindWindow("SeerWindowClass", null).DangerousGetHandle();
return handle != IntPtr.Zero && handle.ToInt64() != -1;
return Task.FromResult(handle != IntPtr.Zero && handle.ToInt64() != -1);
}
}
}
2 changes: 1 addition & 1 deletion src/Files.App/Services/QuickAccessService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Files.App.Services
{
internal class QuickAccessService : IQuickAccessService
{
private readonly static string guid = "::{679f85cb-0220-4080-b29b-5540cc05aab6}";
private static readonly string guid = "::{679f85cb-0220-4080-b29b-5540cc05aab6}";

public async Task<IEnumerable<ShellFileItem>> GetPinnedFoldersAsync()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Services/SideloadUpdateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public async Task CheckLatestReleaseNotesAsync(CancellationToken cancellationTok
if (!IsAppUpdated)
return;

var result = await GetLatestReleaseNotesAsync();
var result = await GetLatestReleaseNotesAsync(cancellationToken);
if (result is not null)
IsReleaseNotesAvailable = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Services/WindowsCompatibilityService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Files.App.Services
/// <inheritdoc cref="IWindowsCompatibilityService"/>
public class WindowsCompatibilityService : IWindowsCompatibilityService
{
private readonly string _registrySubPath = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers";
private const string RegistrySubPath = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers";

/// <inheritdoc/>
public WindowsCompatibilityOptions GetCompatibilityOptionsForPath(string filePath)
Expand Down
6 changes: 3 additions & 3 deletions src/Files.App/UserControls/Widgets/RecentFilesWidget.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public override List<ContextMenuFlyoutItemViewModel> GetItemMenuItems(WidgetCard

public async Task RefreshWidgetAsync()
{
IsRecentFilesDisabledInWindows = App.RecentItemsManager.CheckIsRecentFilesEnabled() is false;
IsRecentFilesDisabledInWindows = RecentItems.CheckIsRecentFilesEnabled() is false;
await App.RecentItemsManager.UpdateRecentFilesAsync();
}

Expand Down Expand Up @@ -381,7 +381,7 @@ private async Task RemoveRecentItemAsync(RecentItem item)

try
{
await App.RecentItemsManager.UnpinFromRecentFiles(item);
await RecentItems.UnpinFromRecentFiles(item);
}
finally
{
Expand All @@ -395,7 +395,7 @@ private async Task ClearRecentItemsAsync()
try
{
recentItemsCollection.Clear();
bool success = App.RecentItemsManager.ClearRecentItems();
bool success = RecentItems.ClearRecentItems();

if (success)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Files.App/Utils/Archives/CompressArchiveModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public async Task<bool> RunCreationAsync()
_fileSystemProgress.ItemsCount = _sizeCalculator.ItemsCount;
_fileSystemProgress.EnumerationCompleted = true;
_fileSystemProgress.Report();
});
}, cts.Token);

foreach (string directory in directories)
{
Expand All @@ -180,15 +180,15 @@ public async Task<bool> RunCreationAsync()
compressor.CompressionMode = CompressionMode.Append;
}

if (files.Any())
if (files.Length != 0)
{
if (string.IsNullOrEmpty(Password))
await compressor.CompressFilesAsync(ArchivePath, files);
else
await compressor.CompressFilesEncryptedAsync(ArchivePath, Password, files);
}

cts.Cancel();
await cts.CancelAsync();

return true;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Files.App/Utils/Archives/DecompressHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ namespace Files.App.Utils.Archives
{
public static class DecompressHelper
{
private readonly static StatusCenterViewModel _statusCenterViewModel = Ioc.Default.GetRequiredService<StatusCenterViewModel>();
private static readonly StatusCenterViewModel _statusCenterViewModel = Ioc.Default.GetRequiredService<StatusCenterViewModel>();

private static IThreadingService _threadingService = Ioc.Default.GetRequiredService<IThreadingService>();
private static readonly IThreadingService _threadingService = Ioc.Default.GetRequiredService<IThreadingService>();

public static async Task<bool> DecompressArchiveAsync(BaseStorageFile archive, BaseStorageFolder destinationFolder, string password, IProgress<StatusCenterItemProgressModel> progress, CancellationToken cancellationToken)
{
Expand Down Expand Up @@ -283,7 +283,7 @@ private static async Task<bool> IsArchiveEncrypted(BaseStorageFile archive)

private static async Task<bool> IsMultipleItems(BaseStorageFile archive)
{
using SevenZipExtractor? zipFile = await GetZipFile(archive);
using var zipFile = await GetZipFile(archive);
if (zipFile is null)
return true;

Expand All @@ -293,7 +293,7 @@ private static async Task<bool> IsMultipleItems(BaseStorageFile archive)
if (pathCharIndex == -1)
return file.FileName;
else
return file.FileName.Substring(0, pathCharIndex);
return file.FileName[..pathCharIndex];
}).Distinct().Count() > 1;
}
}
Expand Down
Loading