SonarQube async method return type set to Task

This commit is contained in:
BONNEVILLE Geoffroy
2018-06-20 17:20:15 +02:00
parent 188233cc81
commit ca377a6684
8 changed files with 22 additions and 20 deletions

View File

@@ -25,7 +25,7 @@ namespace ModernKeePass.Actions
}
catch (Exception ex)
{
MessageDialogHelper.ShowErrorDialog(ex);
MessageDialogHelper.ShowErrorDialog(ex).Wait();
return false;
}
}

View File

@@ -39,7 +39,7 @@ namespace ModernKeePass
#region Event Handlers
private void OnUnhandledException(object sender, UnhandledExceptionEventArgs unhandledExceptionEventArgs)
private async void OnUnhandledException(object sender, UnhandledExceptionEventArgs unhandledExceptionEventArgs)
{
// Save the argument exception because it's cleared on first access
var exception = unhandledExceptionEventArgs.Exception;
@@ -54,7 +54,7 @@ namespace ModernKeePass
if (realException is SaveException)
{
unhandledExceptionEventArgs.Handled = true;
MessageDialogHelper.ShowActionDialog(resource.GetResourceValue("MessageDialogSaveErrorTitle"),
await MessageDialogHelper.ShowActionDialog(resource.GetResourceValue("MessageDialogSaveErrorTitle"),
realException.InnerException.Message,
resource.GetResourceValue("MessageDialogSaveErrorButtonSaveAs"),
resource.GetResourceValue("MessageDialogSaveErrorButtonDiscard"),
@@ -90,7 +90,7 @@ namespace ModernKeePass
OnLaunchOrActivated(args);
}
private void OnLaunchOrActivated(IActivatedEventArgs e)
private async void OnLaunchOrActivated(IActivatedEventArgs e)
{
#if DEBUG
@@ -116,7 +116,7 @@ namespace ModernKeePass
{
//TODO: Load state from previously terminated application
#if DEBUG
MessageDialogHelper.ShowNotificationDialog("App terminated", "Windows or an error made the app terminate");
await MessageDialogHelper.ShowNotificationDialog("App terminated", "Windows or an error made the app terminate");
#endif
}
@@ -132,7 +132,7 @@ namespace ModernKeePass
Window.Current.Activate();
}
private void OnResuming(object sender, object e)
private async void OnResuming(object sender, object e)
{
var currentFrame = Window.Current.Content as Frame;
var database = DatabaseService.Instance;
@@ -151,7 +151,7 @@ namespace ModernKeePass
{
currentFrame?.Navigate(typeof(MainPage));
#if DEBUG
MessageDialogHelper.ShowErrorDialog(ex);
await MessageDialogHelper.ShowErrorDialog(ex);
#endif
ToastNotificationHelper.ShowGenericToast("App suspended", "Database was closed (changes were saved)");
}

View File

@@ -1,11 +1,12 @@
using System;
using System.Threading.Tasks;
using Windows.UI.Popups;
namespace ModernKeePass.Common
{
public static class MessageDialogHelper
{
public static async void ShowActionDialog(string title, string contentText, string actionButtonText, string cancelButtonText, UICommandInvokedHandler actionCommand, UICommandInvokedHandler cancelCommand)
public static async Task ShowActionDialog(string title, string contentText, string actionButtonText, string cancelButtonText, UICommandInvokedHandler actionCommand, UICommandInvokedHandler cancelCommand)
{
// Create the message dialog and set its content
var messageDialog = CreateBasicDialog(title, contentText, cancelButtonText, cancelCommand);
@@ -17,7 +18,7 @@ namespace ModernKeePass.Common
await messageDialog.ShowAsync();
}
public static async void ShowErrorDialog(Exception exception)
public static async Task ShowErrorDialog(Exception exception)
{
if (exception == null) return;
// Create the message dialog and set its content
@@ -27,7 +28,7 @@ namespace ModernKeePass.Common
await messageDialog.ShowAsync();
}
public static async void ShowNotificationDialog(string title, string message)
public static async Task ShowNotificationDialog(string title, string message)
{
var dialog = CreateBasicDialog(title, message, "OK");

View File

@@ -215,7 +215,7 @@ namespace ModernKeePass.ViewModels
}
catch (Exception e)
{
MessageDialogHelper.ShowErrorDialog(e);
MessageDialogHelper.ShowErrorDialog(e).Wait();
}
}
@@ -229,7 +229,7 @@ namespace ModernKeePass.ViewModels
}
catch (Exception e)
{
MessageDialogHelper.ShowErrorDialog(e);
MessageDialogHelper.ShowErrorDialog(e).Wait();
}
}

View File

@@ -1,4 +1,5 @@
using Windows.Storage;
using System.Threading.Tasks;
using Windows.Storage;
using ModernKeePass.Common;
using ModernKeePass.Interfaces;
using ModernKeePass.Services;
@@ -30,10 +31,10 @@ namespace ModernKeePass.ViewModels
public void UpdateAccessTime()
{
UpdateAccessTime(RecentService.Instance);
UpdateAccessTime(RecentService.Instance).Wait();
}
public async void UpdateAccessTime(IRecentService recent)
public async Task UpdateAccessTime(IRecentService recent)
{
await recent.GetFileAsync(Token);
}

View File

@@ -55,14 +55,14 @@ namespace ModernKeePass.Views
#endregion
private void DeleteButton_Click(object sender, RoutedEventArgs e)
private async void DeleteButton_Click(object sender, RoutedEventArgs e)
{
var resource = new ResourcesService();
var message = Model.IsRecycleOnDelete
? resource.GetResourceValue("EntryRecyclingConfirmation")
: resource.GetResourceValue("EntryDeletingConfirmation");
var text = Model.IsRecycleOnDelete ? resource.GetResourceValue("EntryRecycled") : resource.GetResourceValue("EntryDeleted");
MessageDialogHelper.ShowActionDialog(resource.GetResourceValue("EntityDeleteTitle"), message,
await MessageDialogHelper.ShowActionDialog(resource.GetResourceValue("EntityDeleteTitle"), message,
resource.GetResourceValue("EntityDeleteActionButton"),
resource.GetResourceValue("EntityDeleteCancelButton"), a =>
{

View File

@@ -97,14 +97,14 @@ namespace ModernKeePass.Views
Frame.Navigate(typeof(EntryDetailPage), entry);
}
private void DeleteButton_Click(object sender, RoutedEventArgs e)
private async void DeleteButton_Click(object sender, RoutedEventArgs e)
{
var resource = new ResourcesService();
var message = Model.IsRecycleOnDelete
? resource.GetResourceValue("GroupRecyclingConfirmation")
: resource.GetResourceValue("GroupDeletingConfirmation");
var text = Model.IsRecycleOnDelete ? resource.GetResourceValue("GroupRecycled") : resource.GetResourceValue("GroupDeleted");
MessageDialogHelper.ShowActionDialog(resource.GetResourceValue("EntityDeleteTitle"), message,
await MessageDialogHelper.ShowActionDialog(resource.GetResourceValue("EntityDeleteTitle"), message,
resource.GetResourceValue("EntityDeleteActionButton"),
resource.GetResourceValue("EntityDeleteCancelButton"), a =>
{

View File

@@ -96,7 +96,7 @@ namespace ModernKeePass.Views.UserControls
var resource = new ResourcesService();
if (database.IsOpen)
{
MessageDialogHelper.ShowActionDialog(resource.GetResourceValue("MessageDialogDBOpenTitle"),
await MessageDialogHelper.ShowActionDialog(resource.GetResourceValue("MessageDialogDBOpenTitle"),
string.Format(resource.GetResourceValue("MessageDialogDBOpenDesc"), database.Name),
resource.GetResourceValue("MessageDialogDBOpenButtonSave"),
resource.GetResourceValue("MessageDialogDBOpenButtonDiscard"),