From fff044c8854a9502db0e4cd97fec6e73c8ca22d5 Mon Sep 17 00:00:00 2001 From: gumbarros Date: Sun, 31 Mar 2024 22:19:13 -0300 Subject: [PATCH] RoslynAnalyzers: Use concrete types when possible for improved performance --- src/Files.App/Data/Factories/ShellContextFlyoutHelper.cs | 2 +- src/Files.App/Data/Models/ItemViewModel.cs | 2 +- src/Files.App/Services/UpdateService.cs | 2 +- src/Files.App/Utils/RecycleBin/RecycleBinManager.cs | 2 +- .../Collection/BulkConcurrentObservableCollection.cs | 2 +- .../Utils/Storage/Collection/ConcurrentCollection.cs | 2 +- .../Utils/Storage/Enumerators/Win32StorageEnumerator.cs | 2 +- src/Files.App/Utils/Storage/Operations/FilesystemHelpers.cs | 2 +- .../Utils/Storage/StorageItems/ZipStorageFolder.cs | 2 +- .../ViewModels/Properties/CompatibilityViewModel.cs | 2 +- src/Files.App/ViewModels/Settings/AboutViewModel.cs | 2 +- src/Files.App/ViewModels/UserControls/SidebarViewModel.cs | 6 +++--- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Files.App/Data/Factories/ShellContextFlyoutHelper.cs b/src/Files.App/Data/Factories/ShellContextFlyoutHelper.cs index 2773f3d5b8db..ddfbae896897 100644 --- a/src/Files.App/Data/Factories/ShellContextFlyoutHelper.cs +++ b/src/Files.App/Data/Factories/ShellContextFlyoutHelper.cs @@ -66,7 +66,7 @@ bool filterMenuItemsImpl(string menuItem) => !string.IsNullOrEmpty(menuItem) } private static void LoadMenuFlyoutItem( - IList menuItemsListLocal, + List menuItemsListLocal, ContextMenu contextMenu, IEnumerable menuFlyoutItems, CancellationToken cancellationToken, diff --git a/src/Files.App/Data/Models/ItemViewModel.cs b/src/Files.App/Data/Models/ItemViewModel.cs index a89c45f5ef52..b7845df79b91 100644 --- a/src/Files.App/Data/Models/ItemViewModel.cs +++ b/src/Files.App/Data/Models/ItemViewModel.cs @@ -38,7 +38,7 @@ public sealed class ItemViewModel : ObservableObject, IDisposable private readonly AsyncManualResetEvent gitChangedEvent; private readonly DispatcherQueue dispatcherQueue; private readonly JsonElement defaultJson = JsonSerializer.SerializeToElement("{}"); - private readonly IStorageCacheController fileListCache = StorageCacheController.GetInstance(); + private readonly StorageCacheController fileListCache = StorageCacheController.GetInstance(); private readonly string folderTypeTextLocalized = "Folder".GetLocalizedResource(); private Task? aProcessQueueAction; diff --git a/src/Files.App/Services/UpdateService.cs b/src/Files.App/Services/UpdateService.cs index d4aabb028428..14cf22e8eccf 100644 --- a/src/Files.App/Services/UpdateService.cs +++ b/src/Files.App/Services/UpdateService.cs @@ -16,7 +16,7 @@ namespace Files.App.Services internal sealed class UpdateService : ObservableObject, IUpdateService { private StoreContext? _storeContext; - private IList? _updatePackages; + private List? _updatePackages; private bool IsMandatory => _updatePackages?.Where(e => e.Mandatory).ToList().Count >= 1; diff --git a/src/Files.App/Utils/RecycleBin/RecycleBinManager.cs b/src/Files.App/Utils/RecycleBin/RecycleBinManager.cs index 95b39b7a3551..a7ed5424582e 100644 --- a/src/Files.App/Utils/RecycleBin/RecycleBinManager.cs +++ b/src/Files.App/Utils/RecycleBin/RecycleBinManager.cs @@ -12,7 +12,7 @@ public sealed class RecycleBinManager { private static readonly Lazy lazy = new(() => new RecycleBinManager()); - private IList? binWatchers; + private List? binWatchers; public event SystemIO.FileSystemEventHandler? RecycleBinItemCreated; diff --git a/src/Files.App/Utils/Storage/Collection/BulkConcurrentObservableCollection.cs b/src/Files.App/Utils/Storage/Collection/BulkConcurrentObservableCollection.cs index 92d159462de8..47dadb7cf226 100644 --- a/src/Files.App/Utils/Storage/Collection/BulkConcurrentObservableCollection.cs +++ b/src/Files.App/Utils/Storage/Collection/BulkConcurrentObservableCollection.cs @@ -487,7 +487,7 @@ public void Order(Func, IEnumerable> func) public void OrderOne(Func, IEnumerable> func, T item) { - IList result; + List result; lock (syncRoot) { result = func.Invoke(collection).ToList(); diff --git a/src/Files.App/Utils/Storage/Collection/ConcurrentCollection.cs b/src/Files.App/Utils/Storage/Collection/ConcurrentCollection.cs index 46f19af65e98..f16ce899f590 100644 --- a/src/Files.App/Utils/Storage/Collection/ConcurrentCollection.cs +++ b/src/Files.App/Utils/Storage/Collection/ConcurrentCollection.cs @@ -243,7 +243,7 @@ public void Order(Func, IEnumerable> func) public void OrderOne(Func, IEnumerable> func, T item) { - IList result; + List result; lock (syncRoot) { diff --git a/src/Files.App/Utils/Storage/Enumerators/Win32StorageEnumerator.cs b/src/Files.App/Utils/Storage/Enumerators/Win32StorageEnumerator.cs index 0e56a6511b4e..a1b1c4917a9a 100644 --- a/src/Files.App/Utils/Storage/Enumerators/Win32StorageEnumerator.cs +++ b/src/Files.App/Utils/Storage/Enumerators/Win32StorageEnumerator.cs @@ -17,7 +17,7 @@ public static class Win32StorageEnumerator private static readonly string folderTypeTextLocalized = "Folder".GetLocalizedResource(); - private static readonly IStorageCacheController fileListCache = StorageCacheController.GetInstance(); + private static readonly StorageCacheController fileListCache = StorageCacheController.GetInstance(); public static async Task> ListEntries( string path, diff --git a/src/Files.App/Utils/Storage/Operations/FilesystemHelpers.cs b/src/Files.App/Utils/Storage/Operations/FilesystemHelpers.cs index 62cf8e732e1d..fca8d72dee6d 100644 --- a/src/Files.App/Utils/Storage/Operations/FilesystemHelpers.cs +++ b/src/Files.App/Utils/Storage/Operations/FilesystemHelpers.cs @@ -24,7 +24,7 @@ public sealed class FilesystemHelpers : IFilesystemHelpers private IShellPage associatedInstance; private readonly IJumpListService jumpListService; - private IFilesystemOperations filesystemOperations; + private ShellFilesystemOperations filesystemOperations; private ItemManipulationModel? itemManipulationModel => associatedInstance.SlimContentPage?.ItemManipulationModel; diff --git a/src/Files.App/Utils/Storage/StorageItems/ZipStorageFolder.cs b/src/Files.App/Utils/Storage/StorageItems/ZipStorageFolder.cs index f68080e65be0..387efd78ffd2 100644 --- a/src/Files.App/Utils/Storage/StorageItems/ZipStorageFolder.cs +++ b/src/Files.App/Utils/Storage/StorageItems/ZipStorageFolder.cs @@ -516,7 +516,7 @@ private static bool CheckAccess(Stream stream) return false; } } - private static async Task CheckAccess(IStorageFile file) + private static async Task CheckAccess(BaseStorageFile file) { return await SafetyExtensions.IgnoreExceptions(async () => { diff --git a/src/Files.App/ViewModels/Properties/CompatibilityViewModel.cs b/src/Files.App/ViewModels/Properties/CompatibilityViewModel.cs index e0ce1db58bbf..c5ed13885e91 100644 --- a/src/Files.App/ViewModels/Properties/CompatibilityViewModel.cs +++ b/src/Files.App/ViewModels/Properties/CompatibilityViewModel.cs @@ -116,7 +116,7 @@ public bool SetCompatibilityOptions() return WindowsCompatibilityService.SetCompatibilityOptionsForPath(ItemPath, CompatibilityOptions); } - private Task ExecuteRunTroubleshooterCommand() + private Task ExecuteRunTroubleshooterCommand() { return LaunchHelper.RunCompatibilityTroubleshooterAsync(ItemPath); } diff --git a/src/Files.App/ViewModels/Settings/AboutViewModel.cs b/src/Files.App/ViewModels/Settings/AboutViewModel.cs index 33ceee30dc14..f26d8239520b 100644 --- a/src/Files.App/ViewModels/Settings/AboutViewModel.cs +++ b/src/Files.App/ViewModels/Settings/AboutViewModel.cs @@ -48,7 +48,7 @@ public AboutViewModel() OpenCrowdinCommand = new AsyncRelayCommand(DoOpenCrowdin); } - private Task OpenLogLocation() + private Task OpenLogLocation() { return Launcher.LaunchFolderAsync(ApplicationData.Current.LocalFolder).AsTask(); } diff --git a/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs b/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs index 92c16d406cbf..5780cc6e9abc 100644 --- a/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs @@ -268,7 +268,7 @@ public SidebarViewModel() ReorderItemsCommand = new AsyncRelayCommand(ReorderItemsAsync); } - private Task CreateItemHomeAsync() + private Task CreateItemHomeAsync() { return CreateSectionAsync(SectionType.Home); } @@ -379,7 +379,7 @@ await lib.CheckDefaultSaveFolderAccess() && else { string drivePath = drive.Path; - IList paths = section.ChildItems.Select(item => item.Path).ToList(); + var paths = section.ChildItems.Select(item => item.Path).ToList(); if (!paths.Contains(drivePath)) { @@ -1276,7 +1276,7 @@ private async Task HandleLocationItemDroppedAsync(LocationItem locationItem, Ite } } - private Task HandleDriveItemDroppedAsync(DriveItem driveItem, ItemDroppedEventArgs args) + private Task HandleDriveItemDroppedAsync(DriveItem driveItem, ItemDroppedEventArgs args) { return FilesystemHelpers.PerformOperationTypeAsync(args.RawEvent.AcceptedOperation, args.RawEvent.DataView, driveItem.Path, false, true); }