* Start working on nullable checks

help me

* Update GlobalConfig.cs

* Finish initial fixup round

* nullability code review
This commit is contained in:
Łukasz Domeradzki
2020-08-22 21:41:01 +02:00
committed by GitHub
parent e5f64ec9dd
commit 9fc1ea65a5
91 changed files with 1996 additions and 2808 deletions

View File

@@ -22,34 +22,30 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Newtonsoft.Json;
namespace ArchiSteamFarm.CustomPlugins.ExamplePlugin {
// This is example class that shows how you can call third-party services within your plugin
// You always wanted from your ASF to post cats, right? Now is your chance!
// P.S. The code is almost 1:1 copy from the one I use in ArchiBoT, you can thank me later
// You've always wanted from your ASF to post cats, right? Now is your chance!
// P.S. The code is almost 1:1 copy from the one I use in ArchiBot, you can thank me later
internal static class CatAPI {
private const string URL = "https://aws.random.cat";
[ItemCanBeNull]
internal static async Task<string> GetRandomCatURL([JetBrains.Annotations.NotNull] WebBrowser webBrowser) {
internal static async Task<string?> GetRandomCatURL(WebBrowser webBrowser) {
if (webBrowser == null) {
throw new ArgumentNullException(nameof(webBrowser));
}
const string request = URL + "/meow";
WebBrowser.ObjectResponse<MeowResponse> response = await webBrowser.UrlGetToJsonObject<MeowResponse>(request).ConfigureAwait(false);
WebBrowser.ObjectResponse<MeowResponse>? response = await webBrowser.UrlGetToJsonObject<MeowResponse>(request).ConfigureAwait(false);
if (response?.Content == null) {
return null;
}
if (string.IsNullOrEmpty(response.Content.Link)) {
ASF.ArchiLogger.LogNullError(nameof(response.Content.Link));
return null;
throw new ArgumentNullException(nameof(response.Content.Link));
}
return Uri.EscapeUriString(response.Content.Link);
@@ -59,7 +55,7 @@ namespace ArchiSteamFarm.CustomPlugins.ExamplePlugin {
private sealed class MeowResponse {
#pragma warning disable 649
[JsonProperty(PropertyName = "file", Required = Required.Always)]
internal readonly string Link;
internal readonly string? Link;
#pragma warning restore 649
[JsonConstructor]