Skip to content

Commit 7958032

Browse files
committed
Removed all warnings.
1 parent f6d1740 commit 7958032

27 files changed

+575
-458
lines changed

src/.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[*.cs]
2+
dotnet_diagnostic.CA1416.severity=silent

src/ElectronNET.API/App.cs

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

src/ElectronNET.API/AutoUpdater.cs

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

33-
BridgeConnector.Socket.Emit("autoUpdater-autoDownload-get");
33+
BridgeConnector.Socket.Emit("autoUpdater-autoDownload-get").FireAndForget();
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).FireAndForget();
4141
}
4242
}
4343

@@ -60,14 +60,13 @@ public bool AutoInstallOnAppQuit
6060
taskCompletionSource.SetResult((bool)result);
6161
});
6262

63-
BridgeConnector.Socket.Emit("autoUpdater-autoInstallOnAppQuit-get");
64-
63+
BridgeConnector.Socket.Emit("autoUpdater-autoInstallOnAppQuit-get").FireAndForget();
6564
return taskCompletionSource.Task;
6665
}).Result;
6766
}
6867
set
6968
{
70-
BridgeConnector.Socket.Emit("autoUpdater-autoInstallOnAppQuit-set", value);
69+
BridgeConnector.Socket.Emit("autoUpdater-autoInstallOnAppQuit-set", value).FireAndForget();
7170
}
7271
}
7372

@@ -91,14 +90,14 @@ public bool AllowPrerelease
9190
taskCompletionSource.SetResult((bool)result);
9291
});
9392

94-
BridgeConnector.Socket.Emit("autoUpdater-allowPrerelease-get");
93+
BridgeConnector.Socket.Emit("autoUpdater-allowPrerelease-get").FireAndForget();
9594

9695
return taskCompletionSource.Task;
9796
}).Result;
9897
}
9998
set
10099
{
101-
BridgeConnector.Socket.Emit("autoUpdater-allowPrerelease-set", value);
100+
BridgeConnector.Socket.Emit("autoUpdater-allowPrerelease-set", value).FireAndForget();
102101
}
103102
}
104103

@@ -120,14 +119,14 @@ public bool FullChangelog
120119
taskCompletionSource.SetResult((bool)result);
121120
});
122121

123-
BridgeConnector.Socket.Emit("autoUpdater-fullChangelog-get");
122+
BridgeConnector.Socket.Emit("autoUpdater-fullChangelog-get").FireAndForget();
124123

125124
return taskCompletionSource.Task;
126125
}).Result;
127126
}
128127
set
129128
{
130-
BridgeConnector.Socket.Emit("autoUpdater-fullChangelog-set", value);
129+
BridgeConnector.Socket.Emit("autoUpdater-fullChangelog-set", value).FireAndForget();
131130
}
132131
}
133132

@@ -150,14 +149,14 @@ public bool AllowDowngrade
150149
taskCompletionSource.SetResult((bool)result);
151150
});
152151

153-
BridgeConnector.Socket.Emit("autoUpdater-allowDowngrade-get");
152+
BridgeConnector.Socket.Emit("autoUpdater-allowDowngrade-get").FireAndForget();
154153

155154
return taskCompletionSource.Task;
156155
}).Result;
157156
}
158157
set
159158
{
160-
BridgeConnector.Socket.Emit("autoUpdater-allowDowngrade-set", value);
159+
BridgeConnector.Socket.Emit("autoUpdater-allowDowngrade-set", value).FireAndForget();
161160
}
162161
}
163162

@@ -178,7 +177,7 @@ public string UpdateConfigPath
178177
taskCompletionSource.SetResult(result.ToString());
179178
});
180179

181-
BridgeConnector.Socket.Emit("autoUpdater-updateConfigPath-get");
180+
BridgeConnector.Socket.Emit("autoUpdater-updateConfigPath-get").FireAndForget();
182181

183182
return taskCompletionSource.Task;
184183
}).Result;
@@ -195,15 +194,14 @@ public Task<SemVer> CurrentVersionAsync
195194
return Task.Run<SemVer>(() =>
196195
{
197196
var taskCompletionSource = new TaskCompletionSource<SemVer>();
198-
199197
BridgeConnector.Socket.On("autoUpdater-currentVersion-get-reply", (result) =>
200198
{
201199
BridgeConnector.Socket.Off("autoUpdater-currentVersion-get-reply");
202200
SemVer version = ((JObject)result).ToObject<SemVer>();
203201
taskCompletionSource.SetResult(version);
204202
});
205-
BridgeConnector.Socket.Emit("autoUpdater-currentVersion-get");
206203

204+
BridgeConnector.Socket.Emit("autoUpdater-currentVersion-get").FireAndForget();
207205
return taskCompletionSource.Task;
208206
});
209207
}
@@ -239,8 +237,8 @@ public Task<string> ChannelAsync
239237
BridgeConnector.Socket.Off("autoUpdater-channel-get-reply");
240238
taskCompletionSource.SetResult(result.ToString());
241239
});
242-
BridgeConnector.Socket.Emit("autoUpdater-channel-get");
243240

241+
BridgeConnector.Socket.Emit("autoUpdater-channel-get").FireAndForget();
244242
return taskCompletionSource.Task;
245243
});
246244
}
@@ -264,7 +262,8 @@ public Task<Dictionary<string, string>> RequestHeadersAsync
264262
Dictionary<string, string> result = ((JObject)headers).ToObject<Dictionary<string, string>>();
265263
taskCompletionSource.SetResult(result);
266264
});
267-
BridgeConnector.Socket.Emit("autoUpdater-requestHeaders-get");
265+
266+
BridgeConnector.Socket.Emit("autoUpdater-requestHeaders-get").FireAndForget();
268267
return taskCompletionSource.Task;
269268
});
270269
}
@@ -277,7 +276,7 @@ public Dictionary<string, string> RequestHeaders
277276
{
278277
set
279278
{
280-
BridgeConnector.Socket.Emit("autoUpdater-requestHeaders-set", JObject.FromObject(value, _jsonSerializer));
279+
BridgeConnector.Socket.Emit("autoUpdater-requestHeaders-set", JObject.FromObject(value, _jsonSerializer)).FireAndForget();
281280
}
282281
}
283282

@@ -295,7 +294,7 @@ public event Action<string> OnError
295294
_error(message.ToString());
296295
});
297296

298-
BridgeConnector.Socket.Emit("register-autoUpdater-error-event", GetHashCode());
297+
BridgeConnector.Socket.Emit("register-autoUpdater-error-event", GetHashCode()).FireAndForget();
299298
}
300299
_error += value;
301300
}
@@ -304,7 +303,9 @@ public event Action<string> OnError
304303
_error -= value;
305304

306305
if (_error == null)
306+
{
307307
BridgeConnector.Socket.Off("autoUpdater-error" + GetHashCode());
308+
}
308309
}
309310
}
310311

@@ -324,7 +325,7 @@ public event Action OnCheckingForUpdate
324325
_checkingForUpdate();
325326
});
326327

327-
BridgeConnector.Socket.Emit("register-autoUpdater-checking-for-update-event", GetHashCode());
328+
BridgeConnector.Socket.Emit("register-autoUpdater-checking-for-update-event", GetHashCode()).FireAndForget();
328329
}
329330
_checkingForUpdate += value;
330331
}
@@ -354,7 +355,7 @@ public event Action<UpdateInfo> OnUpdateAvailable
354355
_updateAvailable(JObject.Parse(updateInfo.ToString()).ToObject<UpdateInfo>());
355356
});
356357

357-
BridgeConnector.Socket.Emit("register-autoUpdater-update-available-event", GetHashCode());
358+
BridgeConnector.Socket.Emit("register-autoUpdater-update-available-event", GetHashCode()).FireAndForget();
358359
}
359360
_updateAvailable += value;
360361
}
@@ -363,7 +364,9 @@ public event Action<UpdateInfo> OnUpdateAvailable
363364
_updateAvailable -= value;
364365

365366
if (_updateAvailable == null)
367+
{
366368
BridgeConnector.Socket.Off("autoUpdater-update-available" + GetHashCode());
369+
}
367370
}
368371
}
369372

@@ -383,7 +386,7 @@ public event Action<UpdateInfo> OnUpdateNotAvailable
383386
_updateNotAvailable(JObject.Parse(updateInfo.ToString()).ToObject<UpdateInfo>());
384387
});
385388

386-
BridgeConnector.Socket.Emit("register-autoUpdater-update-not-available-event", GetHashCode());
389+
BridgeConnector.Socket.Emit("register-autoUpdater-update-not-available-event", GetHashCode()).FireAndForget();
387390
}
388391
_updateNotAvailable += value;
389392
}
@@ -392,7 +395,9 @@ public event Action<UpdateInfo> OnUpdateNotAvailable
392395
_updateNotAvailable -= value;
393396

394397
if (_updateNotAvailable == null)
398+
{
395399
BridgeConnector.Socket.Off("autoUpdater-update-not-available" + GetHashCode());
400+
}
396401
}
397402
}
398403

@@ -412,7 +417,7 @@ public event Action<ProgressInfo> OnDownloadProgress
412417
_downloadProgress(JObject.Parse(progressInfo.ToString()).ToObject<ProgressInfo>());
413418
});
414419

415-
BridgeConnector.Socket.Emit("register-autoUpdater-download-progress-event", GetHashCode());
420+
BridgeConnector.Socket.Emit("register-autoUpdater-download-progress-event", GetHashCode()).FireAndForget();
416421
}
417422
_downloadProgress += value;
418423
}
@@ -421,7 +426,9 @@ public event Action<ProgressInfo> OnDownloadProgress
421426
_downloadProgress -= value;
422427

423428
if (_downloadProgress == null)
429+
{
424430
BridgeConnector.Socket.Off("autoUpdater-download-progress" + GetHashCode());
431+
}
425432
}
426433
}
427434

@@ -441,7 +448,7 @@ public event Action<UpdateInfo> OnUpdateDownloaded
441448
_updateDownloaded(JObject.Parse(updateInfo.ToString()).ToObject<UpdateInfo>());
442449
});
443450

444-
BridgeConnector.Socket.Emit("register-autoUpdater-update-downloaded-event", GetHashCode());
451+
BridgeConnector.Socket.Emit("register-autoUpdater-update-downloaded-event", GetHashCode()).FireAndForget();
445452
}
446453
_updateDownloaded += value;
447454
}
@@ -450,7 +457,9 @@ public event Action<UpdateInfo> OnUpdateDownloaded
450457
_updateDownloaded -= value;
451458

452459
if (_updateDownloaded == null)
460+
{
453461
BridgeConnector.Socket.Off("autoUpdater-update-downloaded" + GetHashCode());
462+
}
454463
}
455464
}
456465

@@ -506,14 +515,17 @@ public Task<UpdateCheckResult> CheckForUpdatesAsync()
506515
{
507516
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesComplete" + guid);
508517
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesError" + guid);
509-
string message = "An error occurred in CheckForUpdatesAsync";
518+
var message = "An error occurred in CheckForUpdatesAsync";
519+
510520
if (error != null && !string.IsNullOrEmpty(error.ToString()))
521+
{
511522
message = JsonConvert.SerializeObject(error);
523+
}
524+
512525
taskCompletionSource.SetException(new Exception(message));
513526
});
514527

515-
BridgeConnector.Socket.Emit("autoUpdaterCheckForUpdates", guid);
516-
528+
BridgeConnector.Socket.Emit("autoUpdaterCheckForUpdates", guid).FireAndForget();
517529
return taskCompletionSource.Task;
518530
}
519531

@@ -534,10 +546,15 @@ public Task<UpdateCheckResult> CheckForUpdatesAndNotifyAsync()
534546
{
535547
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesAndNotifyComplete" + guid);
536548
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesAndNotifyError" + guid);
549+
537550
if (updateCheckResult == null)
551+
{
538552
taskCompletionSource.SetResult(null);
553+
}
539554
else
555+
{
540556
taskCompletionSource.SetResult(JObject.Parse(updateCheckResult.ToString()).ToObject<UpdateCheckResult>());
557+
}
541558
}
542559
catch (Exception ex)
543560
{
@@ -548,14 +565,17 @@ public Task<UpdateCheckResult> CheckForUpdatesAndNotifyAsync()
548565
{
549566
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesAndNotifyComplete" + guid);
550567
BridgeConnector.Socket.Off("autoUpdaterCheckForUpdatesAndNotifyError" + guid);
551-
string message = "An error occurred in autoUpdaterCheckForUpdatesAndNotify";
568+
var message = "An error occurred in autoUpdaterCheckForUpdatesAndNotify";
569+
552570
if (error != null)
571+
{
553572
message = JsonConvert.SerializeObject(error);
573+
}
574+
554575
taskCompletionSource.SetException(new Exception(message));
555576
});
556577

557-
BridgeConnector.Socket.Emit("autoUpdaterCheckForUpdatesAndNotify", guid);
558-
578+
BridgeConnector.Socket.Emit("autoUpdaterCheckForUpdatesAndNotify", guid).FireAndForget();
559579
return taskCompletionSource.Task;
560580
}
561581

@@ -570,7 +590,7 @@ public Task<UpdateCheckResult> CheckForUpdatesAndNotifyAsync()
570590
/// <param name="isForceRunAfter">Run the app after finish even on silent install. Not applicable for macOS. Ignored if `isSilent` is set to `false`.</param>
571591
public void QuitAndInstall(bool isSilent = false, bool isForceRunAfter = false)
572592
{
573-
BridgeConnector.Socket.Emit("autoUpdaterQuitAndInstall", isSilent, isForceRunAfter);
593+
BridgeConnector.Socket.Emit("autoUpdaterQuitAndInstall", isSilent, isForceRunAfter).FireAndForget();
574594
}
575595

576596
/// <summary>
@@ -580,16 +600,15 @@ public void QuitAndInstall(bool isSilent = false, bool isForceRunAfter = false)
580600
public Task<string> DownloadUpdateAsync()
581601
{
582602
var taskCompletionSource = new TaskCompletionSource<string>();
583-
string guid = Guid.NewGuid().ToString();
603+
var guid = Guid.NewGuid().ToString();
584604

585605
BridgeConnector.Socket.On("autoUpdaterDownloadUpdateComplete" + guid, (downloadedPath) =>
586606
{
587607
BridgeConnector.Socket.Off("autoUpdaterDownloadUpdateComplete" + guid);
588608
taskCompletionSource.SetResult(downloadedPath.ToString());
589609
});
590610

591-
BridgeConnector.Socket.Emit("autoUpdaterDownloadUpdate", guid);
592-
611+
BridgeConnector.Socket.Emit("autoUpdaterDownloadUpdate", guid).FireAndForget();
593612
return taskCompletionSource.Task;
594613
}
595614

@@ -600,16 +619,15 @@ public Task<string> DownloadUpdateAsync()
600619
public Task<string> GetFeedURLAsync()
601620
{
602621
var taskCompletionSource = new TaskCompletionSource<string>();
603-
string guid = Guid.NewGuid().ToString();
622+
var guid = Guid.NewGuid().ToString();
604623

605624
BridgeConnector.Socket.On("autoUpdaterGetFeedURLComplete" + guid, (downloadedPath) =>
606625
{
607626
BridgeConnector.Socket.Off("autoUpdaterGetFeedURLComplete" + guid);
608627
taskCompletionSource.SetResult(downloadedPath.ToString());
609628
});
610629

611-
BridgeConnector.Socket.Emit("autoUpdaterGetFeedURL", guid);
612-
630+
BridgeConnector.Socket.Emit("autoUpdaterGetFeedURL", guid).FireAndForget();
613631
return taskCompletionSource.Task;
614632
}
615633

src/ElectronNET.API/BrowserView.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ public Rectangle Bounds
4545
taskCompletionSource.SetResult((Rectangle)result);
4646
});
4747

48-
BridgeConnector.Socket.Emit("browserView-getBounds", Id);
48+
BridgeConnector.Socket.Emit("browserView-getBounds", Id).FireAndForget();
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)).FireAndForget();
5656
}
5757
}
5858

@@ -74,7 +74,7 @@ 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)).FireAndForget();
7878
}
7979

8080
/// <summary>
@@ -85,7 +85,7 @@ public void SetAutoResize(AutoResizeOptions options)
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).FireAndForget();
8989
}
9090

9191
private JsonSerializer _jsonSerializer = new JsonSerializer()

0 commit comments

Comments
 (0)