Skip to content

Commit

Permalink
refactor(cs): respond to new async void Rider inspection
Browse files Browse the repository at this point in the history
  • Loading branch information
toverux committed Dec 12, 2024
1 parent 72dadfa commit b348ed4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 17 deletions.
4 changes: 2 additions & 2 deletions HallOfFame.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/BLANK_LINES_AFTER_CONTROL_TRANSFER_STATEMENTS/@EntryValue">1</s:Int64>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/BLANK_LINES_AFTER_MULTILINE_STATEMENTS/@EntryValue">1</s:Int64>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/BLANK_LINES_AROUND_SINGLE_LINE_AUTO_PROPERTY/@EntryValue">1</s:Int64>
Expand All @@ -9,7 +9,7 @@
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/BLANK_LINES_BEFORE_BLOCK_STATEMENTS/@EntryValue">1</s:Int64>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/BLANK_LINES_BEFORE_CONTROL_TRANSFER_STATEMENTS/@EntryValue">1</s:Int64>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/BLANK_LINES_BEFORE_MULTILINE_STATEMENTS/@EntryValue">1</s:Int64>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/BLANK_LINES_BEFORE_SINGLE_LINE_COMMENT/@EntryValue">1</s:Int64>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/BLANK_LINES_BEFORE_SINGLE_LINE_COMMENT/@EntryValue">0</s:Int64>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_NESTED_FIXED_STMT/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_NESTED_FOR_STMT/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_NESTED_FOREACH_STMT/@EntryValue">True</s:Boolean>
Expand Down
1 change: 1 addition & 0 deletions HallOfFame/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ private void ShowNoParadoxConnectionWarningDialog() {
/// Whether to debounce the method if it's called multiple times in a short
/// period (keystrokes while typing username).
/// </param>
// ReSharper disable once AsyncVoidMethod
private async void UpdateCreator(
bool nameOnly,
bool silent,
Expand Down
11 changes: 6 additions & 5 deletions HallOfFame/Systems/GameUISystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,15 @@ private int GetPopulation() {
/// the user to set one and the method will not proceed.
/// </summary>
private async void TakeScreenshot() {
// Early exit if the user has not set a creator name.
if (this.CheckShouldSetCreatorName()) {
return;
}

// This bricks the current game session if this throws, so we will
// handle exceptions properly here, as there is a non-zero chance of
// failure in this section (notably due to I/O).
try {
// Early exit if the user has not set a creator name.
if (this.CheckShouldSetCreatorName()) {
return;
}

await this.DoTakeScreenshot();
}
catch (Exception ex) {
Expand Down Expand Up @@ -394,6 +394,7 @@ private void ClearScreenshot() {
}
}

// ReSharper disable once AsyncVoidMethod
private async void UploadScreenshot() {
if (this.CurrentScreenshot is null) {
Mod.Log.Warn(
Expand Down
10 changes: 5 additions & 5 deletions HallOfFame/Systems/MenuNotificationSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ protected override void OnUpdate() {
/// fire-and-forget manner, and it should be designed to never throw.
/// </summary>
private async void LoadAndShowNotification() {
if (this.notificationShownOrLoading) {
return;
}
try {
if (this.notificationShownOrLoading) {
return;
}

this.notificationShownOrLoading = true;
this.notificationShownOrLoading = true;

try {
if (this.notificationUISystem is null) {
Mod.Log.ErrorSilent($"{nameof(NotificationUISystem)} is null.");

Expand Down
14 changes: 9 additions & 5 deletions HallOfFame/Systems/MenuUISystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,9 @@ internal async void LoadScreenshotById(string screenshotId) {
/// Switches the current screenshot to the previous if there is one
/// (<see cref="screenshotsQueue"/>).
/// The method is `async void` because it is designed to be called in a
/// fire-and-forget manner, and it should be designed to never throw.
/// fire-and-forget manner, and it must be designed to never throw.
/// </summary>
// ReSharper disable once AsyncVoidMethod
private async void PreviousScreenshot() {
if (this.isRefreshingBinding.value) {
return;
Expand Down Expand Up @@ -250,6 +251,7 @@ private async void PreviousScreenshot() {
/// The method is `async void` because it is designed to be called in a
/// fire-and-forget manner, and it should be designed to never throw.
/// </summary>
// ReSharper disable once AsyncVoidMethod
private async void NextScreenshot() {
if (this.isRefreshingBinding.value) {
return;
Expand Down Expand Up @@ -316,6 +318,7 @@ private async void NextScreenshot() {
return;

// Fire-and-forget async method that should be designed to never throw.
// ReSharper disable once AsyncVoidMethod
async void PreloadNextScreenshot() {
// Variable used below to avoid infinite loops when there is only
// one screenshot in database (that can happen during development).
Expand Down Expand Up @@ -436,6 +439,7 @@ async void MarkViewed() {
/// The method is `async void` because it is designed to be called in a
/// fire-and-forget manner, and it should be designed to never throw.
/// </summary>
// ReSharper disable once AsyncVoidMethod
private async void FavoriteScreenshot() {
if (this.isTogglingFavorite ||
this.isRefreshingBinding.value ||
Expand Down Expand Up @@ -524,11 +528,11 @@ private void ReportScreenshot() {
return;

async void OnConfirmOrCancel(int choice) {
if (choice is not 0) {
return;
}

try {
if (choice is not 0) {
return;
}

await HttpQueries.ReportScreenshot(screenshot.Id);

var successDialog = new MessageDialog(
Expand Down

0 comments on commit b348ed4

Please sign in to comment.