Skip to content

Commit 846b744

Browse files
committed
fix: Avoid warning CS4014: Call is not awaited
Eliminate warning CS4014 by explicitly discarding the returned Task by assigning it to `_`.
1 parent b9b76f4 commit 846b744

22 files changed

+502
-502
lines changed

src/ElectronNET.API/App.cs

Lines changed: 67 additions & 67 deletions
Large diffs are not rendered by default.

src/ElectronNET.API/AutoUpdater.cs

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ public bool AutoDownload
3030
taskCompletionSource.SetResult((bool)result);
3131
});
3232

33-
BridgeConnector.Socket.Emit("autoUpdater-autoDownload-get");
33+
_ = BridgeConnector.Socket.Emit("autoUpdater-autoDownload-get");
3434

3535
return taskCompletionSource.Task;
3636
}).Result;
3737
}
3838
set
3939
{
40-
BridgeConnector.Socket.Emit("autoUpdater-autoDownload-set", value);
40+
_ = BridgeConnector.Socket.Emit("autoUpdater-autoDownload-set", value);
4141
}
4242
}
4343

4444
/// <summary>
4545
/// Whether to automatically install a downloaded update on app quit (if `QuitAndInstall` was not called before).
46-
///
46+
///
4747
/// Applicable only on Windows and Linux.
4848
/// </summary>
4949
public bool AutoInstallOnAppQuit
@@ -60,21 +60,21 @@ public bool AutoInstallOnAppQuit
6060
taskCompletionSource.SetResult((bool)result);
6161
});
6262

63-
BridgeConnector.Socket.Emit("autoUpdater-autoInstallOnAppQuit-get");
63+
_ = BridgeConnector.Socket.Emit("autoUpdater-autoInstallOnAppQuit-get");
6464

6565
return taskCompletionSource.Task;
6666
}).Result;
6767
}
6868
set
6969
{
70-
BridgeConnector.Socket.Emit("autoUpdater-autoInstallOnAppQuit-set", value);
70+
_ = BridgeConnector.Socket.Emit("autoUpdater-autoInstallOnAppQuit-set", value);
7171
}
7272
}
7373

7474
/// <summary>
75-
/// *GitHub provider only.* Whether to allow update to pre-release versions.
75+
/// *GitHub provider only.* Whether to allow update to pre-release versions.
7676
/// Defaults to "true" if application version contains prerelease components (e.g. "0.12.1-alpha.1", here "alpha" is a prerelease component), otherwise "false".
77-
///
77+
///
7878
/// If "true", downgrade will be allowed("allowDowngrade" will be set to "true").
7979
/// </summary>
8080
public bool AllowPrerelease
@@ -91,19 +91,19 @@ public bool AllowPrerelease
9191
taskCompletionSource.SetResult((bool)result);
9292
});
9393

94-
BridgeConnector.Socket.Emit("autoUpdater-allowPrerelease-get");
94+
_ = BridgeConnector.Socket.Emit("autoUpdater-allowPrerelease-get");
9595

9696
return taskCompletionSource.Task;
9797
}).Result;
9898
}
9999
set
100100
{
101-
BridgeConnector.Socket.Emit("autoUpdater-allowPrerelease-set", value);
101+
_ = BridgeConnector.Socket.Emit("autoUpdater-allowPrerelease-set", value);
102102
}
103103
}
104104

105105
/// <summary>
106-
/// *GitHub provider only.*
106+
/// *GitHub provider only.*
107107
/// Get all release notes (from current version to latest), not just the latest (Default is false).
108108
/// </summary>
109109
public bool FullChangelog
@@ -120,14 +120,14 @@ public bool FullChangelog
120120
taskCompletionSource.SetResult((bool)result);
121121
});
122122

123-
BridgeConnector.Socket.Emit("autoUpdater-fullChangelog-get");
123+
_ = BridgeConnector.Socket.Emit("autoUpdater-fullChangelog-get");
124124

125125
return taskCompletionSource.Task;
126126
}).Result;
127127
}
128128
set
129129
{
130-
BridgeConnector.Socket.Emit("autoUpdater-fullChangelog-set", value);
130+
_ = BridgeConnector.Socket.Emit("autoUpdater-fullChangelog-set", value);
131131
}
132132
}
133133

@@ -150,14 +150,14 @@ public bool AllowDowngrade
150150
taskCompletionSource.SetResult((bool)result);
151151
});
152152

153-
BridgeConnector.Socket.Emit("autoUpdater-allowDowngrade-get");
153+
_ = BridgeConnector.Socket.Emit("autoUpdater-allowDowngrade-get");
154154

155155
return taskCompletionSource.Task;
156156
}).Result;
157157
}
158158
set
159159
{
160-
BridgeConnector.Socket.Emit("autoUpdater-allowDowngrade-set", value);
160+
_ = BridgeConnector.Socket.Emit("autoUpdater-allowDowngrade-set", value);
161161
}
162162
}
163163

@@ -178,7 +178,7 @@ public string UpdateConfigPath
178178
taskCompletionSource.SetResult(result.ToString());
179179
});
180180

181-
BridgeConnector.Socket.Emit("autoUpdater-updateConfigPath-get");
181+
_ = BridgeConnector.Socket.Emit("autoUpdater-updateConfigPath-get");
182182

183183
return taskCompletionSource.Task;
184184
}).Result;
@@ -202,15 +202,15 @@ public Task<SemVer> CurrentVersionAsync
202202
SemVer version = ((JObject)result).ToObject<SemVer>();
203203
taskCompletionSource.SetResult(version);
204204
});
205-
BridgeConnector.Socket.Emit("autoUpdater-currentVersion-get");
205+
_ = BridgeConnector.Socket.Emit("autoUpdater-currentVersion-get");
206206

207207
return taskCompletionSource.Task;
208208
});
209209
}
210210
}
211211

212212
/// <summary>
213-
/// Get the update channel. Not applicable for GitHub.
213+
/// Get the update channel. Not applicable for GitHub.
214214
/// Doesn’t return channel from the update configuration, only if was previously set.
215215
/// </summary>
216216
[Obsolete("Use the asynchronous version ChannelAsync instead")]
@@ -223,7 +223,7 @@ public string Channel
223223
}
224224

225225
/// <summary>
226-
/// Get the update channel. Not applicable for GitHub.
226+
/// Get the update channel. Not applicable for GitHub.
227227
/// Doesn’t return channel from the update configuration, only if was previously set.
228228
/// </summary>
229229
public Task<string> ChannelAsync
@@ -239,7 +239,7 @@ public Task<string> ChannelAsync
239239
BridgeConnector.Socket.Off("autoUpdater-channel-get-reply");
240240
taskCompletionSource.SetResult(result.ToString());
241241
});
242-
BridgeConnector.Socket.Emit("autoUpdater-channel-get");
242+
_ = BridgeConnector.Socket.Emit("autoUpdater-channel-get");
243243

244244
return taskCompletionSource.Task;
245245
});
@@ -264,7 +264,7 @@ public Task<Dictionary<string, string>> RequestHeadersAsync
264264
Dictionary<string, string> result = ((JObject)headers).ToObject<Dictionary<string, string>>();
265265
taskCompletionSource.SetResult(result);
266266
});
267-
BridgeConnector.Socket.Emit("autoUpdater-requestHeaders-get");
267+
_ = BridgeConnector.Socket.Emit("autoUpdater-requestHeaders-get");
268268
return taskCompletionSource.Task;
269269
});
270270
}
@@ -277,7 +277,7 @@ public Dictionary<string, string> RequestHeaders
277277
{
278278
set
279279
{
280-
BridgeConnector.Socket.Emit("autoUpdater-requestHeaders-set", JObject.FromObject(value, _jsonSerializer));
280+
_ = BridgeConnector.Socket.Emit("autoUpdater-requestHeaders-set", JObject.FromObject(value, _jsonSerializer));
281281
}
282282
}
283283

@@ -295,7 +295,7 @@ public event Action<string> OnError
295295
_error(message.ToString());
296296
});
297297

298-
BridgeConnector.Socket.Emit("register-autoUpdater-error-event", GetHashCode());
298+
_ = BridgeConnector.Socket.Emit("register-autoUpdater-error-event", GetHashCode());
299299
}
300300
_error += value;
301301
}
@@ -324,7 +324,7 @@ public event Action OnCheckingForUpdate
324324
_checkingForUpdate();
325325
});
326326

327-
BridgeConnector.Socket.Emit("register-autoUpdater-checking-for-update-event", GetHashCode());
327+
_ = BridgeConnector.Socket.Emit("register-autoUpdater-checking-for-update-event", GetHashCode());
328328
}
329329
_checkingForUpdate += value;
330330
}
@@ -340,7 +340,7 @@ public event Action OnCheckingForUpdate
340340
private event Action _checkingForUpdate;
341341

342342
/// <summary>
343-
/// Emitted when there is an available update.
343+
/// Emitted when there is an available update.
344344
/// The update is downloaded automatically if AutoDownload is true.
345345
/// </summary>
346346
public event Action<UpdateInfo> OnUpdateAvailable
@@ -354,7 +354,7 @@ public event Action<UpdateInfo> OnUpdateAvailable
354354
_updateAvailable(JObject.Parse(updateInfo.ToString()).ToObject<UpdateInfo>());
355355
});
356356

357-
BridgeConnector.Socket.Emit("register-autoUpdater-update-available-event", GetHashCode());
357+
_ = BridgeConnector.Socket.Emit("register-autoUpdater-update-available-event", GetHashCode());
358358
}
359359
_updateAvailable += value;
360360
}
@@ -383,7 +383,7 @@ public event Action<UpdateInfo> OnUpdateNotAvailable
383383
_updateNotAvailable(JObject.Parse(updateInfo.ToString()).ToObject<UpdateInfo>());
384384
});
385385

386-
BridgeConnector.Socket.Emit("register-autoUpdater-update-not-available-event", GetHashCode());
386+
_ = BridgeConnector.Socket.Emit("register-autoUpdater-update-not-available-event", GetHashCode());
387387
}
388388
_updateNotAvailable += value;
389389
}
@@ -412,7 +412,7 @@ public event Action<ProgressInfo> OnDownloadProgress
412412
_downloadProgress(JObject.Parse(progressInfo.ToString()).ToObject<ProgressInfo>());
413413
});
414414

415-
BridgeConnector.Socket.Emit("register-autoUpdater-download-progress-event", GetHashCode());
415+
_ = BridgeConnector.Socket.Emit("register-autoUpdater-download-progress-event", GetHashCode());
416416
}
417417
_downloadProgress += value;
418418
}
@@ -441,7 +441,7 @@ public event Action<UpdateInfo> OnUpdateDownloaded
441441
_updateDownloaded(JObject.Parse(updateInfo.ToString()).ToObject<UpdateInfo>());
442442
});
443443

444-
BridgeConnector.Socket.Emit("register-autoUpdater-update-downloaded-event", GetHashCode());
444+
_ = BridgeConnector.Socket.Emit("register-autoUpdater-update-downloaded-event", GetHashCode());
445445
}
446446
_updateDownloaded += value;
447447
}
@@ -512,14 +512,14 @@ public Task<UpdateCheckResult> CheckForUpdatesAsync()
512512
taskCompletionSource.SetException(new Exception(message));
513513
});
514514

515-
BridgeConnector.Socket.Emit("autoUpdaterCheckForUpdates", guid);
515+
_ = BridgeConnector.Socket.Emit("autoUpdaterCheckForUpdates", guid);
516516

517517
return taskCompletionSource.Task;
518518
}
519519

520520
/// <summary>
521521
/// Asks the server whether there is an update.
522-
///
522+
///
523523
/// This will immediately download an update, then install when the app quits.
524524
/// </summary>
525525
/// <returns></returns>
@@ -554,23 +554,23 @@ public Task<UpdateCheckResult> CheckForUpdatesAndNotifyAsync()
554554
taskCompletionSource.SetException(new Exception(message));
555555
});
556556

557-
BridgeConnector.Socket.Emit("autoUpdaterCheckForUpdatesAndNotify", guid);
557+
_ = BridgeConnector.Socket.Emit("autoUpdaterCheckForUpdatesAndNotify", guid);
558558

559559
return taskCompletionSource.Task;
560560
}
561561

562562
/// <summary>
563563
/// Restarts the app and installs the update after it has been downloaded.
564564
/// It should only be called after `update-downloaded` has been emitted.
565-
///
565+
///
566566
/// Note: QuitAndInstall() will close all application windows first and only emit `before-quit` event on `app` after that.
567567
/// This is different from the normal quit event sequence.
568568
/// </summary>
569569
/// <param name="isSilent">*windows-only* Runs the installer in silent mode. Defaults to `false`.</param>
570570
/// <param name="isForceRunAfter">Run the app after finish even on silent install. Not applicable for macOS. Ignored if `isSilent` is set to `false`.</param>
571571
public void QuitAndInstall(bool isSilent = false, bool isForceRunAfter = false)
572572
{
573-
BridgeConnector.Socket.Emit("autoUpdaterQuitAndInstall", isSilent, isForceRunAfter);
573+
_ = BridgeConnector.Socket.Emit("autoUpdaterQuitAndInstall", isSilent, isForceRunAfter);
574574
}
575575

576576
/// <summary>
@@ -588,7 +588,7 @@ public Task<string> DownloadUpdateAsync()
588588
taskCompletionSource.SetResult(downloadedPath.ToString());
589589
});
590590

591-
BridgeConnector.Socket.Emit("autoUpdaterDownloadUpdate", guid);
591+
_ = BridgeConnector.Socket.Emit("autoUpdaterDownloadUpdate", guid);
592592

593593
return taskCompletionSource.Task;
594594
}
@@ -608,7 +608,7 @@ public Task<string> GetFeedURLAsync()
608608
taskCompletionSource.SetResult(downloadedPath.ToString());
609609
});
610610

611-
BridgeConnector.Socket.Emit("autoUpdaterGetFeedURL", guid);
611+
_ = BridgeConnector.Socket.Emit("autoUpdaterGetFeedURL", guid);
612612

613613
return taskCompletionSource.Task;
614614
}

src/ElectronNET.API/BrowserView.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
namespace ElectronNET.API
88
{
99
/// <summary>
10-
/// A BrowserView can be used to embed additional web content into a BrowserWindow.
11-
/// It is like a child window, except that it is positioned relative to its owning window.
10+
/// A BrowserView can be used to embed additional web content into a BrowserWindow.
11+
/// It is like a child window, except that it is positioned relative to its owning window.
1212
/// It is meant to be an alternative to the webview tag.
1313
/// </summary>
1414
public class BrowserView
@@ -28,7 +28,7 @@ public class BrowserView
2828

2929
/// <summary>
3030
/// Resizes and moves the view to the supplied bounds relative to the window.
31-
///
31+
///
3232
/// (experimental)
3333
/// </summary>
3434
public Rectangle Bounds
@@ -45,21 +45,21 @@ public Rectangle Bounds
4545
taskCompletionSource.SetResult((Rectangle)result);
4646
});
4747

48-
BridgeConnector.Socket.Emit("browserView-getBounds", Id);
48+
_ = BridgeConnector.Socket.Emit("browserView-getBounds", Id);
4949

5050
return taskCompletionSource.Task;
5151
}).Result;
5252
}
5353
set
5454
{
55-
BridgeConnector.Socket.Emit("browserView-setBounds", Id, JObject.FromObject(value, _jsonSerializer));
55+
_ = BridgeConnector.Socket.Emit("browserView-setBounds", Id, JObject.FromObject(value, _jsonSerializer));
5656
}
5757
}
5858

5959
/// <summary>
6060
/// BrowserView
6161
/// </summary>
62-
internal BrowserView(int id)
62+
internal BrowserView(int id)
6363
{
6464
Id = id;
6565

@@ -74,18 +74,18 @@ internal BrowserView(int id)
7474
/// <param name="options"></param>
7575
public void SetAutoResize(AutoResizeOptions options)
7676
{
77-
BridgeConnector.Socket.Emit("browserView-setAutoResize", Id, JObject.FromObject(options, _jsonSerializer));
77+
_ = BridgeConnector.Socket.Emit("browserView-setAutoResize", Id, JObject.FromObject(options, _jsonSerializer));
7878
}
7979

8080
/// <summary>
8181
/// Color in #aarrggbb or #argb form. The alpha channel is optional.
82-
///
82+
///
8383
/// (experimental)
8484
/// </summary>
8585
/// <param name="color">Color in #aarrggbb or #argb form. The alpha channel is optional.</param>
8686
public void SetBackgroundColor(string color)
8787
{
88-
BridgeConnector.Socket.Emit("browserView-setBackgroundColor", Id, color);
88+
_ = BridgeConnector.Socket.Emit("browserView-setBackgroundColor", Id, color);
8989
}
9090

9191
private JsonSerializer _jsonSerializer = new JsonSerializer()

0 commit comments

Comments
 (0)