From eadd35ac095852670ac60af6501d292ea86e2253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Thu, 31 Oct 2024 13:01:54 +0100 Subject: [PATCH] Enable explicit nullable definition for Core --- Cloudflare/ClientOptions.cs | 2 +- Cloudflare/Cloudflare.csproj | 1 + Cloudflare/CloudflareClient.cs | 22 +++++++++++----------- Cloudflare/Extensions/EnumExtensions.cs | 2 +- Cloudflare/Interfaces/ICloudflareClient.cs | 10 +++++----- Cloudflare/Models/AccountBase.cs | 4 ++-- Cloudflare/Models/OwnerBase.cs | 6 +++--- Cloudflare/Responses/CloudflareResponse.cs | 4 ++-- Cloudflare/Responses/ResponseInfo.cs | 2 +- 9 files changed, 27 insertions(+), 26 deletions(-) diff --git a/Cloudflare/ClientOptions.cs b/Cloudflare/ClientOptions.cs index 0b45b25..0372a77 100644 --- a/Cloudflare/ClientOptions.cs +++ b/Cloudflare/ClientOptions.cs @@ -50,6 +50,6 @@ namespace AMWD.Net.Api.Cloudflare /// /// Gets or sets the proxy information. /// - public virtual IWebProxy Proxy { get; set; } + public virtual IWebProxy? Proxy { get; set; } } } diff --git a/Cloudflare/Cloudflare.csproj b/Cloudflare/Cloudflare.csproj index d566fa4..6716e16 100644 --- a/Cloudflare/Cloudflare.csproj +++ b/Cloudflare/Cloudflare.csproj @@ -4,6 +4,7 @@ netstandard2.0;net6.0 {semvertag:main}{!:-dev} + enable true false diff --git a/Cloudflare/CloudflareClient.cs b/Cloudflare/CloudflareClient.cs index d78de10..ee3a03f 100644 --- a/Cloudflare/CloudflareClient.cs +++ b/Cloudflare/CloudflareClient.cs @@ -37,7 +37,7 @@ namespace AMWD.Net.Api.Cloudflare /// The email address of the Cloudflare account. /// The API key of the Cloudflare account. /// The client options (optional). - public CloudflareClient(string emailAddress, string apiKey, ClientOptions clientOptions = null) + public CloudflareClient(string emailAddress, string apiKey, ClientOptions? clientOptions = null) : this(new ApiKeyAuthentication(emailAddress, apiKey), clientOptions) { } @@ -46,7 +46,7 @@ namespace AMWD.Net.Api.Cloudflare /// /// The API token. /// The client options (optional). - public CloudflareClient(string apiToken, ClientOptions clientOptions = null) + public CloudflareClient(string apiToken, ClientOptions? clientOptions = null) : this(new ApiTokenAuthentication(apiToken), clientOptions) { } @@ -55,7 +55,7 @@ namespace AMWD.Net.Api.Cloudflare /// /// The authentication information. /// The client options (optional). - public CloudflareClient(IAuthentication authentication, ClientOptions clientOptions = null) + public CloudflareClient(IAuthentication authentication, ClientOptions? clientOptions = null) { if (authentication == null) throw new ArgumentNullException(nameof(authentication)); @@ -82,7 +82,7 @@ namespace AMWD.Net.Api.Cloudflare } /// - public async Task> GetAsync(string requestPath, IQueryParameterFilter queryFilter = null, CancellationToken cancellationToken = default) + public async Task> GetAsync(string requestPath, IQueryParameterFilter? queryFilter = null, CancellationToken cancellationToken = default) { ThrowIfDisposed(); ValidateRequestPath(requestPath); @@ -94,7 +94,7 @@ namespace AMWD.Net.Api.Cloudflare } /// - public async Task> PostAsync(string requestPath, TRequest request, IQueryParameterFilter queryFilter = null, CancellationToken cancellationToken = default) + public async Task> PostAsync(string requestPath, TRequest? request, IQueryParameterFilter? queryFilter = null, CancellationToken cancellationToken = default) { ThrowIfDisposed(); ValidateRequestPath(requestPath); @@ -107,7 +107,7 @@ namespace AMWD.Net.Api.Cloudflare } /// - public async Task> PutAsync(string requestPath, TRequest request, CancellationToken cancellationToken = default) + public async Task> PutAsync(string requestPath, TRequest? request, CancellationToken cancellationToken = default) { ThrowIfDisposed(); ValidateRequestPath(requestPath); @@ -120,7 +120,7 @@ namespace AMWD.Net.Api.Cloudflare } /// - public async Task> DeleteAsync(string requestPath, IQueryParameterFilter queryFilter = null, CancellationToken cancellationToken = default) + public async Task> DeleteAsync(string requestPath, IQueryParameterFilter? queryFilter = null, CancellationToken cancellationToken = default) { ThrowIfDisposed(); ValidateRequestPath(requestPath); @@ -132,7 +132,7 @@ namespace AMWD.Net.Api.Cloudflare } /// - public async Task> PatchAsync(string requestPath, TRequest request, CancellationToken cancellationToken = default) + public async Task> PatchAsync(string requestPath, TRequest? request, CancellationToken cancellationToken = default) { ThrowIfDisposed(); ValidateRequestPath(requestPath); @@ -178,7 +178,7 @@ namespace AMWD.Net.Api.Cloudflare { string version = typeof(CloudflareClient).Assembly .GetCustomAttribute() - .InformationalVersion; + ?.InformationalVersion ?? "unknown"; HttpMessageHandler handler; try @@ -258,7 +258,7 @@ namespace AMWD.Net.Api.Cloudflare } } - private string BuildRequestUrl(string requestPath, IQueryParameterFilter queryFilter = null) + private string BuildRequestUrl(string requestPath, IQueryParameterFilter? queryFilter = null) { var dict = new Dictionary(); @@ -284,7 +284,7 @@ namespace AMWD.Net.Api.Cloudflare return $"{requestPath}?{query}"; } - private static HttpContent ConvertRequest(T request) + private static HttpContent? ConvertRequest(T request) { if (request == null) return null; diff --git a/Cloudflare/Extensions/EnumExtensions.cs b/Cloudflare/Extensions/EnumExtensions.cs index ac5c556..8fa3456 100644 --- a/Cloudflare/Extensions/EnumExtensions.cs +++ b/Cloudflare/Extensions/EnumExtensions.cs @@ -13,7 +13,7 @@ namespace AMWD.Net.Api.Cloudflare /// Gets the of the when available, otherwise the . /// /// The enum value. - public static string GetEnumMemberValue(this Enum value) + public static string? GetEnumMemberValue(this Enum value) { var fieldInfo = value.GetType().GetField(value.ToString()); if (fieldInfo == null) diff --git a/Cloudflare/Interfaces/ICloudflareClient.cs b/Cloudflare/Interfaces/ICloudflareClient.cs index 03e985b..bf80082 100644 --- a/Cloudflare/Interfaces/ICloudflareClient.cs +++ b/Cloudflare/Interfaces/ICloudflareClient.cs @@ -19,7 +19,7 @@ namespace AMWD.Net.Api.Cloudflare /// The request path (extending the base URL). /// The query parameters. /// A cancellation token used to propagate notification that this operation should be canceled. - Task> GetAsync(string requestPath, IQueryParameterFilter queryFilter = null, CancellationToken cancellationToken = default); + Task> GetAsync(string requestPath, IQueryParameterFilter? queryFilter = null, CancellationToken cancellationToken = default); /// /// Makes a POST request to the Cloudflare API. @@ -33,7 +33,7 @@ namespace AMWD.Net.Api.Cloudflare /// The request content. /// The query parameters. /// A cancellation token used to propagate notification that this operation should be canceled. - Task> PostAsync(string requestPath, TRequest request, IQueryParameterFilter queryFilter = null, CancellationToken cancellationToken = default); + Task> PostAsync(string requestPath, TRequest? request, IQueryParameterFilter? queryFilter = null, CancellationToken cancellationToken = default); /// /// Makes a PUT request to the Cloudflare API. @@ -46,7 +46,7 @@ namespace AMWD.Net.Api.Cloudflare /// The request path (extending the base URL). /// The request content. /// A cancellation token used to propagate notification that this operation should be canceled. - Task> PutAsync(string requestPath, TRequest request, CancellationToken cancellationToken = default); + Task> PutAsync(string requestPath, TRequest? request, CancellationToken cancellationToken = default); /// /// Makes a DELETE request to the Cloudflare API. @@ -59,7 +59,7 @@ namespace AMWD.Net.Api.Cloudflare /// The query parameters. /// A cancellation token used to propagate notification that this operation should be canceled. /// - Task> DeleteAsync(string requestPath, IQueryParameterFilter queryFilter = null, CancellationToken cancellationToken = default); + Task> DeleteAsync(string requestPath, IQueryParameterFilter? queryFilter = null, CancellationToken cancellationToken = default); /// /// Makes a PATCH request to the Cloudflare API. @@ -72,6 +72,6 @@ namespace AMWD.Net.Api.Cloudflare /// The request path (extending the base URL). /// The request content. /// A cancellation token used to propagate notification that this operation should be canceled. - Task> PatchAsync(string requestPath, TRequest request, CancellationToken cancellationToken = default); + Task> PatchAsync(string requestPath, TRequest? request, CancellationToken cancellationToken = default); } } diff --git a/Cloudflare/Models/AccountBase.cs b/Cloudflare/Models/AccountBase.cs index ad49c41..e96f9e6 100644 --- a/Cloudflare/Models/AccountBase.cs +++ b/Cloudflare/Models/AccountBase.cs @@ -10,12 +10,12 @@ /// // <= 32 characters [JsonProperty("id")] - public string Id { get; set; } + public string? Id { get; set; } /// /// The name of the account. /// [JsonProperty("name")] - public string Name { get; set; } + public string? Name { get; set; } } } diff --git a/Cloudflare/Models/OwnerBase.cs b/Cloudflare/Models/OwnerBase.cs index 59d19a7..b7ac768 100644 --- a/Cloudflare/Models/OwnerBase.cs +++ b/Cloudflare/Models/OwnerBase.cs @@ -10,18 +10,18 @@ /// // <= 32 characters [JsonProperty("id")] - public string Id { get; set; } + public string? Id { get; set; } /// /// Name of the owner. /// [JsonProperty("name")] - public string Name { get; set; } + public string? Name { get; set; } /// /// The type of owner. /// [JsonProperty("type")] - public string Type { get; set; } + public string? Type { get; set; } } } diff --git a/Cloudflare/Responses/CloudflareResponse.cs b/Cloudflare/Responses/CloudflareResponse.cs index 772a023..8073f99 100644 --- a/Cloudflare/Responses/CloudflareResponse.cs +++ b/Cloudflare/Responses/CloudflareResponse.cs @@ -11,7 +11,7 @@ namespace AMWD.Net.Api.Cloudflare /// Information about the result of the request. /// [JsonProperty("result_info")] - public PaginationInfo ResultInfo { get; set; } + public PaginationInfo? ResultInfo { get; set; } /// /// Whether the API call was successful. @@ -42,6 +42,6 @@ namespace AMWD.Net.Api.Cloudflare /// The result of the API call. /// [JsonProperty("result")] - public T Result { get; set; } + public T? Result { get; set; } } } diff --git a/Cloudflare/Responses/ResponseInfo.cs b/Cloudflare/Responses/ResponseInfo.cs index 747901f..3ad9cde 100644 --- a/Cloudflare/Responses/ResponseInfo.cs +++ b/Cloudflare/Responses/ResponseInfo.cs @@ -15,6 +15,6 @@ /// The message. /// [JsonProperty("message")] - public string Message { get; set; } + public string? Message { get; set; } } }