Skip to content

Commit

Permalink
Code Quality: Remove Async suffix from event methods (#13567)
Browse files Browse the repository at this point in the history
  • Loading branch information
A-Loot authored Oct 24, 2023
1 parent d2456b7 commit 1e8d456
Show file tree
Hide file tree
Showing 59 changed files with 259 additions and 259 deletions.
4 changes: 2 additions & 2 deletions src/Files.App/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ private void EnsureSuperEarlyWindow()

// Hook events for the window
window.Activated += Window_Activated;
window.Closed += Window_ClosedAsync;
window.Closed += Window_Closed;

// Attempt to activate it
window.Activate();
Expand Down Expand Up @@ -294,7 +294,7 @@ public void OnActivated(AppActivationArguments activatedEventArgs)
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="args">Details about the suspend request.</param>
private async void Window_ClosedAsync(object sender, WindowEventArgs args)
private async void Window_Closed(object sender, WindowEventArgs args)
{
// Save application state and stop any background activity

Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Data/Items/DriveItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,12 @@ public FrameworkElement? ItemDecorator
Width = 16
}
};
itemDecorator.Click += ItemDecorator_ClickAsync;
itemDecorator.Click += ItemDecorator_Click;
return itemDecorator;
}
}

private async void ItemDecorator_ClickAsync(object sender, RoutedEventArgs e)
private async void ItemDecorator_Click(object sender, RoutedEventArgs e)
{
var result = await DriveHelpers.EjectDeviceAsync(Path);
await UIHelpers.ShowDeviceEjectResultAsync(Type, result);
Expand Down
16 changes: 8 additions & 8 deletions src/Files.App/Data/Models/DrivesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ public DrivesViewModel(IRemovableDrivesService removableDrivesService, ISizeProv
watcher = removableDrivesService.CreateWatcher();
watcher.DeviceAdded += Watcher_DeviceAdded;
watcher.DeviceRemoved += Watcher_DeviceRemoved;
watcher.DeviceModified += Watcher_DeviceModifiedAsync;
watcher.EnumerationCompleted += Watcher_EnumerationCompletedAsync;
watcher.DeviceModified += Watcher_DeviceModified;
watcher.EnumerationCompleted += Watcher_EnumerationCompleted;
}

private async void Watcher_EnumerationCompletedAsync(object? sender, System.EventArgs e)
private async void Watcher_EnumerationCompleted(object? sender, System.EventArgs e)
{
logger.LogDebug("Watcher_EnumerationCompleted");
await folderSizeProvider.CleanAsync();
}

private async void Watcher_DeviceModifiedAsync(object? sender, string e)
private async void Watcher_DeviceModified(object? sender, string e)
{
var matchingDriveEjected = Drives.FirstOrDefault(x => Path.GetFullPath(x.Path) == Path.GetFullPath(e));
if (matchingDriveEjected != null)
Expand All @@ -68,7 +68,7 @@ private void Watcher_DeviceRemoved(object? sender, string e)
}

// Update the collection on the ui-thread.
Watcher_EnumerationCompletedAsync(null, EventArgs.Empty);
Watcher_EnumerationCompleted(null, EventArgs.Empty);
}

private void Watcher_DeviceAdded(object? sender, ILocatableFolder e)
Expand All @@ -90,7 +90,7 @@ private void Watcher_DeviceAdded(object? sender, ILocatableFolder e)
Drives.Add(e);
}

Watcher_EnumerationCompletedAsync(null, EventArgs.Empty);
Watcher_EnumerationCompleted(null, EventArgs.Empty);
}

public async Task UpdateDrivesAsync()
Expand All @@ -116,8 +116,8 @@ public void Dispose()
watcher.Stop();
watcher.DeviceAdded -= Watcher_DeviceAdded;
watcher.DeviceRemoved -= Watcher_DeviceRemoved;
watcher.DeviceModified -= Watcher_DeviceModifiedAsync;
watcher.EnumerationCompleted -= Watcher_EnumerationCompletedAsync;
watcher.DeviceModified -= Watcher_DeviceModified;
watcher.EnumerationCompleted -= Watcher_EnumerationCompleted;
}
}
}
36 changes: 18 additions & 18 deletions src/Files.App/Data/Models/ItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,10 @@ public ItemViewModel(FolderSettingsViewModel folderSettingsViewModel)
enumFolderSemaphore = new SemaphoreSlim(1, 1);
dispatcherQueue = DispatcherQueue.GetForCurrentThread();

UserSettingsService.OnSettingChangedEvent += UserSettingsService_OnSettingChangedEventAsync;
fileTagsSettingsService.OnSettingImportedEvent += FileTagsSettingsService_OnSettingUpdatedAsync;
fileTagsSettingsService.OnTagsUpdated += FileTagsSettingsService_OnSettingUpdatedAsync;
folderSizeProvider.SizeChanged += FolderSizeProvider_SizeChangedAsync;
UserSettingsService.OnSettingChangedEvent += UserSettingsService_OnSettingChangedEvent;
fileTagsSettingsService.OnSettingImportedEvent += FileTagsSettingsService_OnSettingUpdated;
fileTagsSettingsService.OnTagsUpdated += FileTagsSettingsService_OnSettingUpdated;
folderSizeProvider.SizeChanged += FolderSizeProvider_SizeChanged;
RecycleBinManager.Default.RecycleBinItemCreated += RecycleBinItemCreatedAsync;
RecycleBinManager.Default.RecycleBinItemDeleted += RecycleBinItemDeletedAsync;
RecycleBinManager.Default.RecycleBinRefreshRequested += RecycleBinRefreshRequestedAsync;
Expand Down Expand Up @@ -482,7 +482,7 @@ private async void RecycleBinItemCreatedAsync(object sender, FileSystemEventArgs
await ApplySingleFileChangeAsync(newListedItem);
}

private async void FolderSizeProvider_SizeChangedAsync(object? sender, SizeChangedEventArgs e)
private async void FolderSizeProvider_SizeChanged(object? sender, SizeChangedEventArgs e)
{
try
{
Expand Down Expand Up @@ -522,7 +522,7 @@ await dispatcherQueue.EnqueueOrInvokeAsync(() =>
}
}

private async void FileTagsSettingsService_OnSettingUpdatedAsync(object? sender, EventArgs e)
private async void FileTagsSettingsService_OnSettingUpdated(object? sender, EventArgs e)
{
await dispatcherQueue.EnqueueOrInvokeAsync(() =>
{
Expand All @@ -531,7 +531,7 @@ await dispatcherQueue.EnqueueOrInvokeAsync(() =>
});
}

private async void UserSettingsService_OnSettingChangedEventAsync(object? sender, SettingChangedEventArgs e)
private async void UserSettingsService_OnSettingChangedEvent(object? sender, SettingChangedEventArgs e)
{
switch (e.SettingName)
{
Expand Down Expand Up @@ -1792,14 +1792,14 @@ await Task.Factory.StartNew(() =>
if (rootFolder.AreQueryOptionsSupported(options))
{
var itemQueryResult = rootFolder.CreateItemQueryWithOptions(options).ToStorageItemQueryResult();
itemQueryResult.ContentsChanged += ItemQueryResult_ContentsChangedAsync;
itemQueryResult.ContentsChanged += ItemQueryResult_ContentsChanged;

// Just get one item to start getting notifications
var watchedItemsOperation = itemQueryResult.GetItemsAsync(0, 1);

watcherCTS.Token.Register(() =>
{
itemQueryResult.ContentsChanged -= ItemQueryResult_ContentsChangedAsync;
itemQueryResult.ContentsChanged -= ItemQueryResult_ContentsChanged;
watchedItemsOperation?.Cancel();
});
}
Expand All @@ -1820,14 +1820,14 @@ private void WatchForWin32FolderChanges(string? folderPath)
NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName
};

watcher.Created += DirectoryWatcher_ChangedAsync;
watcher.Deleted += DirectoryWatcher_ChangedAsync;
watcher.Renamed += DirectoryWatcher_ChangedAsync;
watcher.Created += DirectoryWatcher_Changed;
watcher.Deleted += DirectoryWatcher_Changed;
watcher.Renamed += DirectoryWatcher_Changed;
watcher.EnableRaisingEvents = true;
}
}

private async void DirectoryWatcher_ChangedAsync(object sender, FileSystemEventArgs e)
private async void DirectoryWatcher_Changed(object sender, FileSystemEventArgs e)
{
Debug.WriteLine($"Directory watcher event: {e.ChangeType}, {e.FullPath}");

Expand All @@ -1837,7 +1837,7 @@ await dispatcherQueue.EnqueueOrInvokeAsync(() =>
});
}

private async void ItemQueryResult_ContentsChangedAsync(IStorageQueryResultBase sender, object args)
private async void ItemQueryResult_ContentsChanged(IStorageQueryResultBase sender, object args)
{
// Query options have to be reapplied otherwise old results are returned
var options = new QueryOptions()
Expand Down Expand Up @@ -2461,10 +2461,10 @@ public void Dispose()
RecycleBinManager.Default.RecycleBinItemCreated -= RecycleBinItemCreatedAsync;
RecycleBinManager.Default.RecycleBinItemDeleted -= RecycleBinItemDeletedAsync;
RecycleBinManager.Default.RecycleBinRefreshRequested -= RecycleBinRefreshRequestedAsync;
UserSettingsService.OnSettingChangedEvent -= UserSettingsService_OnSettingChangedEventAsync;
fileTagsSettingsService.OnSettingImportedEvent -= FileTagsSettingsService_OnSettingUpdatedAsync;
fileTagsSettingsService.OnTagsUpdated -= FileTagsSettingsService_OnSettingUpdatedAsync;
folderSizeProvider.SizeChanged -= FolderSizeProvider_SizeChangedAsync;
UserSettingsService.OnSettingChangedEvent -= UserSettingsService_OnSettingChangedEvent;
fileTagsSettingsService.OnSettingImportedEvent -= FileTagsSettingsService_OnSettingUpdated;
fileTagsSettingsService.OnTagsUpdated -= FileTagsSettingsService_OnSettingUpdated;
folderSizeProvider.SizeChanged -= FolderSizeProvider_SizeChanged;
DefaultIcons.Clear();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Dialogs/AddItemDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Grid.RowSpan="4"
BorderThickness="0"
CornerRadius="{StaticResource OverlayCornerRadius}"
Loaded="AddItemDialog_LoadedAsync"
Loaded="AddItemDialog_Loaded"
RequestedTheme="{x:Bind helpers:ThemeHelper.RootTheme}"
SecondaryButtonText="{helpers:ResourceString Name=Cancel}"
Style="{StaticResource DefaultContentDialogStyle}"
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Dialogs/AddItemDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private void ListView_ItemClick(object sender, ItemClickEventArgs e)
Hide();
}

private async void AddItemDialog_LoadedAsync(object sender, RoutedEventArgs e)
private async void AddItemDialog_Loaded(object sender, RoutedEventArgs e)
{
var itemTypes = addItemService.GetEntries();
await ViewModel.AddItemsToListAsync(itemTypes);
Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Helpers/ShareItemHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public static void ShareItems(IEnumerable<ListedItem> itemsToShare)
IntPtr result = interop.GetForWindow(MainWindow.Instance.WindowHandle, InteropHelpers.DataTransferManagerInteropIID);

var manager = WinRT.MarshalInterface<DataTransferManager>.FromAbi(result);
manager.DataRequested += new TypedEventHandler<DataTransferManager, DataRequestedEventArgs>(Manager_DataRequestedAsync);
manager.DataRequested += new TypedEventHandler<DataTransferManager, DataRequestedEventArgs>(Manager_DataRequested);

interop.ShowShareUIForWindow(MainWindow.Instance.WindowHandle);

async void Manager_DataRequestedAsync(DataTransferManager sender, DataRequestedEventArgs args)
async void Manager_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
{
DataRequestDeferral dataRequestDeferral = args.Request.GetDeferral();
List<IStorageItem> items = new();
Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Helpers/UI/ThemeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static bool Initialize()

// Registering to color changes, thus we notice when user changes theme system wide
UiSettings = new UISettings();
UiSettings.ColorValuesChanged += UiSettings_ColorValuesChangedAsync;
UiSettings.ColorValuesChanged += UiSettings_ColorValuesChanged;

return true;
}
Expand All @@ -77,7 +77,7 @@ public static void ApplyResources()
ApplyTheme();
}

private static async void UiSettings_ColorValuesChangedAsync(UISettings sender, object args)
private static async void UiSettings_ColorValuesChanged(UISettings sender, object args)
{
// Make sure we have a reference to our window so we dispatch a UI change
if (currentApplicationWindow is null)
Expand Down
6 changes: 3 additions & 3 deletions src/Files.App/Services/UserSizeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public UserSizeProvider()
provider = GetProvider();
provider.SizeChanged += Provider_SizeChanged;

folderPreferences.PropertyChanged += FolderPreferences_PropertyChangedAsync;
folderPreferences.PropertyChanged += FolderPreferences_PropertyChanged;
}

public Task CleanAsync()
Expand All @@ -37,13 +37,13 @@ public bool TryGetSize(string path, out ulong size)
public void Dispose()
{
provider.Dispose();
folderPreferences.PropertyChanged -= FolderPreferences_PropertyChangedAsync;
folderPreferences.PropertyChanged -= FolderPreferences_PropertyChanged;
}

private ISizeProvider GetProvider()
=> folderPreferences.CalculateFolderSizes ? new DrivesSizeProvider() : new NoSizeProvider();

private async void FolderPreferences_PropertyChangedAsync(object sender, PropertyChangedEventArgs e)
private async void FolderPreferences_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName is nameof(IFoldersSettingsService.CalculateFolderSizes))
{
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/UserControls/FilePreviews/HtmlPreview.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
x:Name="WebViewControl"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Loaded="WebViewControl_LoadedAsync" />
Loaded="WebViewControl_Loaded" />

</Border>
</UserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public HtmlPreview(HtmlPreviewViewModel model)

public HtmlPreviewViewModel ViewModel { get; set; }

private async void WebViewControl_LoadedAsync(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
private async void WebViewControl_Loaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
await WebViewControl.EnsureCoreWebView2Async();
WebViewControl.CoreWebView2.SetVirtualHostNameToFolderMapping(
Expand Down
10 changes: 5 additions & 5 deletions src/Files.App/UserControls/PathBreadcrumb.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
AutomationProperties.Name="{x:Bind Title, Mode=OneWay}"
Background="Transparent"
DragLeave="PathBoxItem_DragLeave"
DragOver="PathBoxItem_DragOverAsync"
Drop="PathBoxItem_DropAsync"
DragOver="PathBoxItem_DragOver"
Drop="PathBoxItem_Drop"
Orientation="Horizontal"
Spacing="4"
Tag="{x:Bind Path, Mode=OneWay}">
Expand Down Expand Up @@ -60,8 +60,8 @@
AutomationProperties.Name="{x:Bind Title, Mode=OneWay}"
Background="Transparent"
DragLeave="PathBoxItem_DragLeave"
DragOver="PathBoxItem_DragOverAsync"
Drop="PathBoxItem_DropAsync"
DragOver="PathBoxItem_DragOver"
Drop="PathBoxItem_Drop"
Orientation="Horizontal"
Spacing="4"
Tag="{x:Bind Path, Mode=OneWay}">
Expand All @@ -71,7 +71,7 @@
Padding="0,4"
FontSize="12"
PointerPressed="PathBoxItem_PointerPressed"
Tapped="PathBoxItem_TappedAsync"
Tapped="PathBoxItem_Tapped"
Text="{x:Bind Title, Mode=OneWay}">
<i:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="PointerEntered">
Expand Down
12 changes: 6 additions & 6 deletions src/Files.App/UserControls/PathBreadcrumb.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ private void PathBoxItem_DragLeave(object sender, DragEventArgs e)
ViewModel.PathBoxItem_DragLeave(sender, e);
}

private async void PathBoxItem_DragOverAsync(object sender, DragEventArgs e)
private async void PathBoxItem_DragOver(object sender, DragEventArgs e)
{
await ViewModel.PathBoxItem_DragOverAsync(sender, e);
await ViewModel.PathBoxItem_DragOver(sender, e);
}

private async void PathBoxItem_DropAsync(object sender, DragEventArgs e)
private async void PathBoxItem_Drop(object sender, DragEventArgs e)
{
await ViewModel.PathBoxItem_DropAsync(sender, e);
await ViewModel.PathBoxItem_Drop(sender, e);
}

private async void PathBoxItem_TappedAsync(object sender, TappedRoutedEventArgs e)
private async void PathBoxItem_Tapped(object sender, TappedRoutedEventArgs e)
{
await ViewModel.PathBoxItem_TappedAsync(sender, e);
await ViewModel.PathBoxItem_Tapped(sender, e);
}

private void PathBoxItem_PointerPressed(object sender, PointerRoutedEventArgs e)
Expand Down
10 changes: 5 additions & 5 deletions src/Files.App/UserControls/TabBar/TabBar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@
TabCloseRequested="TabView_TabCloseRequested"
TabDragCompleted="TabView_TabDragCompleted"
TabDragStarting="TabView_TabDragStarting"
TabDroppedOutside="TabView_TabDroppedOutsideAsync"
TabDroppedOutside="TabView_TabDroppedOutside"
TabItemsChanged="TabView_TabItemsChanged"
TabItemsSource="{x:Bind Items, Mode=OneWay}"
TabStripDragOver="TabView_TabStripDragOver"
TabStripDrop="TabView_TabStripDropAsync"
TabStripDrop="TabView_TabStripDrop"
Visibility="{x:Bind TabStripVisibility, Mode=OneWay}">

<!-- Item Template -->
Expand All @@ -92,9 +92,9 @@
<TabViewItem
AllowDrop="{x:Bind AllowStorageItemDrop, Mode=OneWay}"
ContextFlyout="{StaticResource TabFlyout}"
DragEnter="TabViewItem_DragEnterAsync"
DragLeave="TabViewItem_DragLeaveAsync"
Drop="TabViewItem_DropAsync"
DragEnter="TabViewItem_DragEnter"
DragLeave="TabViewItem_DragLeave"
Drop="TabViewItem_Drop"
Header="{x:Bind Header, Mode=OneWay}"
IconSource="{x:Bind IconSource, Mode=OneWay}"
Loaded="TabViewItem_Loaded"
Expand Down
Loading

0 comments on commit 1e8d456

Please sign in to comment.