(bugfix): missing default null

This commit is contained in:
Maksym Sadovnychyy 2024-09-28 12:35:14 +02:00
parent c77741498f
commit 5ef1d00bba
2 changed files with 41 additions and 41 deletions

View File

@ -8,7 +8,7 @@
<!-- NuGet package metadata --> <!-- NuGet package metadata -->
<PackageId>MaksIT.Results</PackageId> <PackageId>MaksIT.Results</PackageId>
<Version>1.0.2</Version> <Version>1.0.3</Version>
<Authors>Maksym Sadovnychyy</Authors> <Authors>Maksym Sadovnychyy</Authors>
<Company>MAKS-IT</Company> <Company>MAKS-IT</Company>
<Product>MaksIT.Results</Product> <Product>MaksIT.Results</Product>

View File

@ -9,14 +9,14 @@ public partial class Result {
/// Returns a result indicating the request was successful and the server returned the requested data. /// Returns a result indicating the request was successful and the server returned the requested data.
/// Corresponds to HTTP status code 200 OK. /// Corresponds to HTTP status code 200 OK.
/// </summary> /// </summary>
public static Result Ok(string? message) => public static Result Ok(string? message = null) =>
Ok(message != null ? [message] : null); Ok(message != null ? [message] : null);
/// <summary> /// <summary>
/// Returns a result indicating the request was successful and the server returned the requested data. /// Returns a result indicating the request was successful and the server returned the requested data.
/// Corresponds to HTTP status code 200 OK. /// Corresponds to HTTP status code 200 OK.
/// </summary> /// </summary>
public static Result Ok(List<string>? messages) { public static Result Ok(List<string>? messages = null) {
return new Result(true, messages ?? [], HttpStatusCode.OK); return new Result(true, messages ?? [], HttpStatusCode.OK);
} }
@ -24,14 +24,14 @@ public partial class Result {
/// Returns a result indicating the request was successful and a new resource was created. /// Returns a result indicating the request was successful and a new resource was created.
/// Corresponds to HTTP status code 201 Created. /// Corresponds to HTTP status code 201 Created.
/// </summary> /// </summary>
public static Result Created(string? message) => public static Result Created(string? message = null) =>
Created(message != null ? [message] : null); Created(message != null ? [message] : null);
/// <summary> /// <summary>
/// Returns a result indicating the request was successful and a new resource was created. /// Returns a result indicating the request was successful and a new resource was created.
/// Corresponds to HTTP status code 201 Created. /// Corresponds to HTTP status code 201 Created.
/// </summary> /// </summary>
public static Result Created(List<string>? messages) { public static Result Created(List<string>? messages = null) {
return new Result(true, messages ?? [], HttpStatusCode.Created); return new Result(true, messages ?? [], HttpStatusCode.Created);
} }
@ -39,14 +39,14 @@ public partial class Result {
/// Returns a result indicating the request has been accepted for processing, but the processing is not yet complete. /// Returns a result indicating the request has been accepted for processing, but the processing is not yet complete.
/// Corresponds to HTTP status code 202 Accepted. /// Corresponds to HTTP status code 202 Accepted.
/// </summary> /// </summary>
public static Result Accepted(string? message) => public static Result Accepted(string? message = null) =>
Accepted(message != null ? [message] : null); Accepted(message != null ? [message] : null);
/// <summary> /// <summary>
/// Returns a result indicating the request has been accepted for processing, but the processing is not yet complete. /// Returns a result indicating the request has been accepted for processing, but the processing is not yet complete.
/// Corresponds to HTTP status code 202 Accepted. /// Corresponds to HTTP status code 202 Accepted.
/// </summary> /// </summary>
public static Result Accepted(List<string>? messages) { public static Result Accepted(List<string>? messages = null) {
return new Result(true, messages ?? [], HttpStatusCode.Accepted); return new Result(true, messages ?? [], HttpStatusCode.Accepted);
} }
@ -54,14 +54,14 @@ public partial class Result {
/// Returns a result indicating the request was successful but the response contains metadata from a source other than the origin server. /// Returns a result indicating the request was successful but the response contains metadata from a source other than the origin server.
/// Corresponds to HTTP status code 203 Non-Authoritative Information. /// Corresponds to HTTP status code 203 Non-Authoritative Information.
/// </summary> /// </summary>
public static Result NonAuthoritativeInformation(string? message) => public static Result NonAuthoritativeInformation(string? message = null) =>
NonAuthoritativeInformation(message != null ? [message] : null); NonAuthoritativeInformation(message != null ? [message] : null);
/// <summary> /// <summary>
/// Returns a result indicating the request was successful but the response contains metadata from a source other than the origin server. /// Returns a result indicating the request was successful but the response contains metadata from a source other than the origin server.
/// Corresponds to HTTP status code 203 Non-Authoritative Information. /// Corresponds to HTTP status code 203 Non-Authoritative Information.
/// </summary> /// </summary>
public static Result NonAuthoritativeInformation(List<string>? messages) { public static Result NonAuthoritativeInformation(List<string>? messages = null) {
return new Result(true, messages ?? [], HttpStatusCode.NonAuthoritativeInformation); return new Result(true, messages ?? [], HttpStatusCode.NonAuthoritativeInformation);
} }
@ -69,14 +69,14 @@ public partial class Result {
/// Returns a result indicating the request was successful but there is no content to send in the response. /// Returns a result indicating the request was successful but there is no content to send in the response.
/// Corresponds to HTTP status code 204 No Content. /// Corresponds to HTTP status code 204 No Content.
/// </summary> /// </summary>
public static Result NoContent(string? message) => public static Result NoContent(string? message = null) =>
ResetContent(message != null ? [message] : null); ResetContent(message != null ? [message] : null);
/// <summary> /// <summary>
/// Returns a result indicating the request was successful but there is no content to send in the response. /// Returns a result indicating the request was successful but there is no content to send in the response.
/// Corresponds to HTTP status code 204 No Content. /// Corresponds to HTTP status code 204 No Content.
/// </summary> /// </summary>
public static Result NoContent(List<string>? messages) { public static Result NoContent(List<string>? messages = null) {
return new Result(true, messages ?? [], HttpStatusCode.NoContent); return new Result(true, messages ?? [], HttpStatusCode.NoContent);
} }
@ -84,14 +84,14 @@ public partial class Result {
/// Returns a result indicating the request was successful, but the user-agent should reset the document view that caused the request. /// Returns a result indicating the request was successful, but the user-agent should reset the document view that caused the request.
/// Corresponds to HTTP status code 205 Reset Content. /// Corresponds to HTTP status code 205 Reset Content.
/// </summary> /// </summary>
public static Result ResetContent(string? message) => public static Result ResetContent(string? message = null) =>
ResetContent(message != null ? [message] : null); ResetContent(message != null ? [message] : null);
/// <summary> /// <summary>
/// Returns a result indicating the request was successful, but the user-agent should reset the document view that caused the request. /// Returns a result indicating the request was successful, but the user-agent should reset the document view that caused the request.
/// Corresponds to HTTP status code 205 Reset Content. /// Corresponds to HTTP status code 205 Reset Content.
/// </summary> /// </summary>
public static Result ResetContent(List<string>? messages) { public static Result ResetContent(List<string>? messages = null) {
return new Result(true, messages ?? [], HttpStatusCode.ResetContent); return new Result(true, messages ?? [], HttpStatusCode.ResetContent);
} }
@ -99,14 +99,14 @@ public partial class Result {
/// Returns a result indicating the request was successful and the server is delivering only part of the resource due to a range header sent by the client. /// Returns a result indicating the request was successful and the server is delivering only part of the resource due to a range header sent by the client.
/// Corresponds to HTTP status code 206 Partial Content. /// Corresponds to HTTP status code 206 Partial Content.
/// </summary> /// </summary>
public static Result PartialContent(string? message) => public static Result PartialContent(string? message = null) =>
PartialContent(message != null ? [message] : null); PartialContent(message != null ? [message] : null);
/// <summary> /// <summary>
/// Returns a result indicating the request was successful and the server is delivering only part of the resource due to a range header sent by the client. /// Returns a result indicating the request was successful and the server is delivering only part of the resource due to a range header sent by the client.
/// Corresponds to HTTP status code 206 Partial Content. /// Corresponds to HTTP status code 206 Partial Content.
/// </summary> /// </summary>
public static Result PartialContent(List<string>? messages) { public static Result PartialContent(List<string>? messages = null) {
return new Result(true, messages ?? [], HttpStatusCode.PartialContent); return new Result(true, messages ?? [], HttpStatusCode.PartialContent);
} }
@ -114,14 +114,14 @@ public partial class Result {
/// Returns a result indicating the request was successful and the response contains multiple status codes, typically used for WebDAV. /// Returns a result indicating the request was successful and the response contains multiple status codes, typically used for WebDAV.
/// Corresponds to HTTP status code 207 Multi-Status. /// Corresponds to HTTP status code 207 Multi-Status.
/// </summary> /// </summary>
public static Result MultiStatus(string? message) => public static Result MultiStatus(string? message = null) =>
MultiStatus(message != null ? [message] : null); MultiStatus(message != null ? [message] : null);
/// <summary> /// <summary>
/// Returns a result indicating the request was successful and the response contains multiple status codes, typically used for WebDAV. /// Returns a result indicating the request was successful and the response contains multiple status codes, typically used for WebDAV.
/// Corresponds to HTTP status code 207 Multi-Status. /// Corresponds to HTTP status code 207 Multi-Status.
/// </summary> /// </summary>
public static Result MultiStatus(List<string>? messages) { public static Result MultiStatus(List<string>? messages = null) {
return new Result(true, messages ?? [], HttpStatusCode.MultiStatus); return new Result(true, messages ?? [], HttpStatusCode.MultiStatus);
} }
@ -129,14 +129,14 @@ public partial class Result {
/// Returns a result indicating the request was successful and the information has already been reported in a previous response. /// Returns a result indicating the request was successful and the information has already been reported in a previous response.
/// Corresponds to HTTP status code 208 Already Reported. /// Corresponds to HTTP status code 208 Already Reported.
/// </summary> /// </summary>
public static Result AlreadyReported(string? message) => public static Result AlreadyReported(string? message = null) =>
AlreadyReported(message != null ? [message] : null); AlreadyReported(message != null ? [message] : null);
/// <summary> /// <summary>
/// Returns a result indicating the request was successful and the information has already been reported in a previous response. /// Returns a result indicating the request was successful and the information has already been reported in a previous response.
/// Corresponds to HTTP status code 208 Already Reported. /// Corresponds to HTTP status code 208 Already Reported.
/// </summary> /// </summary>
public static Result AlreadyReported(List<string>? messages) { public static Result AlreadyReported(List<string>? messages = null) {
return new Result(true, messages ?? [], HttpStatusCode.AlreadyReported); return new Result(true, messages ?? [], HttpStatusCode.AlreadyReported);
} }
@ -144,14 +144,14 @@ public partial class Result {
/// Returns a result indicating the request was successful and the server fulfilled the request for the resource using the delta encoding method. /// Returns a result indicating the request was successful and the server fulfilled the request for the resource using the delta encoding method.
/// Corresponds to HTTP status code 226 IM Used. /// Corresponds to HTTP status code 226 IM Used.
/// </summary> /// </summary>
public static Result IMUsed(string? message) => public static Result IMUsed(string? message = null) =>
IMUsed(message != null ? [message] : null); IMUsed(message != null ? [message] : null);
/// <summary> /// <summary>
/// Returns a result indicating the request was successful and the server fulfilled the request for the resource using the delta encoding method. /// Returns a result indicating the request was successful and the server fulfilled the request for the resource using the delta encoding method.
/// Corresponds to HTTP status code 226 IM Used. /// Corresponds to HTTP status code 226 IM Used.
/// </summary> /// </summary>
public static Result IMUsed(List<string>? messages) { public static Result IMUsed(List<string>? messages = null) {
return new Result(true, messages ?? [], (HttpStatusCode)226); // 226 is the official status code for IM Used return new Result(true, messages ?? [], (HttpStatusCode)226); // 226 is the official status code for IM Used
} }
} }
@ -161,14 +161,14 @@ public partial class Result<T> : Result {
/// Returns a result indicating the request was successful and the server returned the requested data. /// Returns a result indicating the request was successful and the server returned the requested data.
/// Corresponds to HTTP status code 200 OK. /// Corresponds to HTTP status code 200 OK.
/// </summary> /// </summary>
public static Result<T> Ok(T? value, string? message) => public static Result<T> Ok(T? value, string? message = null) =>
Ok(value, message != null ? [message] : null); Ok(value, message != null ? [message] : null);
/// <summary> /// <summary>
/// Returns a result indicating the request was successful and the server returned the requested data. /// Returns a result indicating the request was successful and the server returned the requested data.
/// Corresponds to HTTP status code 200 OK. /// Corresponds to HTTP status code 200 OK.
/// </summary> /// </summary>
public static Result<T> Ok(T? value, List<string>? messages) { public static Result<T> Ok(T? value, List<string>? messages = null) {
return new Result<T>(value, true, messages ?? [], HttpStatusCode.OK); return new Result<T>(value, true, messages ?? [], HttpStatusCode.OK);
} }
@ -176,14 +176,14 @@ public partial class Result<T> : Result {
/// Returns a result indicating the request was successful and a new resource was created. /// Returns a result indicating the request was successful and a new resource was created.
/// Corresponds to HTTP status code 201 Created. /// Corresponds to HTTP status code 201 Created.
/// </summary> /// </summary>
public static Result<T> Created(T? value, string? message) => public static Result<T> Created(T? value, string? message = null) =>
Created(value, message != null ? [message] : null); Created(value, message != null ? [message] : null);
/// <summary> /// <summary>
/// Returns a result indicating the request was successful and a new resource was created. /// Returns a result indicating the request was successful and a new resource was created.
/// Corresponds to HTTP status code 201 Created. /// Corresponds to HTTP status code 201 Created.
/// </summary> /// </summary>
public static Result<T> Created(T? value, List<string>? messages) { public static Result<T> Created(T? value, List<string>? messages = null) {
return new Result<T>(value, true, messages ?? [], HttpStatusCode.Created); return new Result<T>(value, true, messages ?? [], HttpStatusCode.Created);
} }
@ -191,14 +191,14 @@ public partial class Result<T> : Result {
/// Returns a result indicating the request has been accepted for processing, but the processing is not yet complete. /// Returns a result indicating the request has been accepted for processing, but the processing is not yet complete.
/// Corresponds to HTTP status code 202 Accepted. /// Corresponds to HTTP status code 202 Accepted.
/// </summary> /// </summary>
public static Result<T> Accepted(T? value, string? message) => public static Result<T> Accepted(T? value, string? message = null) =>
Accepted(value, message != null ? [message] : null); Accepted(value, message != null ? [message] : null);
/// <summary> /// <summary>
/// Returns a result indicating the request has been accepted for processing, but the processing is not yet complete. /// Returns a result indicating the request has been accepted for processing, but the processing is not yet complete.
/// Corresponds to HTTP status code 202 Accepted. /// Corresponds to HTTP status code 202 Accepted.
/// </summary> /// </summary>
public static Result<T> Accepted(T? value, List<string>? messages) { public static Result<T> Accepted(T? value, List<string>? messages = null) {
return new Result<T>(value, true, messages ?? [], HttpStatusCode.Accepted); return new Result<T>(value, true, messages ?? [], HttpStatusCode.Accepted);
} }
@ -206,14 +206,14 @@ public partial class Result<T> : Result {
/// Returns a result indicating the request was successful but the response contains metadata from a source other than the origin server. /// Returns a result indicating the request was successful but the response contains metadata from a source other than the origin server.
/// Corresponds to HTTP status code 203 Non-Authoritative Information. /// Corresponds to HTTP status code 203 Non-Authoritative Information.
/// </summary> /// </summary>
public static Result<T> NonAuthoritativeInformation(T? value, string? message) => public static Result<T> NonAuthoritativeInformation(T? value, string? message = null) =>
NonAuthoritativeInformation(value, message != null ? [message] : null); NonAuthoritativeInformation(value, message != null ? [message] : null);
/// <summary> /// <summary>
/// Returns a result indicating the request was successful but the response contains metadata from a source other than the origin server. /// Returns a result indicating the request was successful but the response contains metadata from a source other than the origin server.
/// Corresponds to HTTP status code 203 Non-Authoritative Information. /// Corresponds to HTTP status code 203 Non-Authoritative Information.
/// </summary> /// </summary>
public static Result<T> NonAuthoritativeInformation(T? value, List<string>? messages) { public static Result<T> NonAuthoritativeInformation(T? value, List<string>? messages = null) {
return new Result<T>(value, true, messages ?? [], HttpStatusCode.NonAuthoritativeInformation); return new Result<T>(value, true, messages ?? [], HttpStatusCode.NonAuthoritativeInformation);
} }
@ -221,14 +221,14 @@ public partial class Result<T> : Result {
/// Returns a result indicating the request was successful but there is no content to send in the response. /// Returns a result indicating the request was successful but there is no content to send in the response.
/// Corresponds to HTTP status code 204 No Content. /// Corresponds to HTTP status code 204 No Content.
/// </summary> /// </summary>
public static Result<T> NoContent(T? value, string? message) => public static Result<T> NoContent(T? value, string? message = null) =>
NoContent(value, message != null ? [message] : null); NoContent(value, message != null ? [message] : null);
/// <summary> /// <summary>
/// Returns a result indicating the request was successful but there is no content to send in the response. /// Returns a result indicating the request was successful but there is no content to send in the response.
/// Corresponds to HTTP status code 204 No Content. /// Corresponds to HTTP status code 204 No Content.
/// </summary> /// </summary>
public static Result<T> NoContent(T? value, List<string>? messages) { public static Result<T> NoContent(T? value, List<string>? messages = null) {
return new Result<T>(value, true, messages ?? [], HttpStatusCode.NoContent); return new Result<T>(value, true, messages ?? [], HttpStatusCode.NoContent);
} }
@ -236,14 +236,14 @@ public partial class Result<T> : Result {
/// Returns a result indicating the request was successful, but the user-agent should reset the document view that caused the request. /// Returns a result indicating the request was successful, but the user-agent should reset the document view that caused the request.
/// Corresponds to HTTP status code 205 Reset Content. /// Corresponds to HTTP status code 205 Reset Content.
/// </summary> /// </summary>
public static Result<T> ResetContent(T? value, string? message) => public static Result<T> ResetContent(T? value, string? message = null) =>
ResetContent(value, message != null ? [message] : null); ResetContent(value, message != null ? [message] : null);
/// <summary> /// <summary>
/// Returns a result indicating the request was successful, but the user-agent should reset the document view that caused the request. /// Returns a result indicating the request was successful, but the user-agent should reset the document view that caused the request.
/// Corresponds to HTTP status code 205 Reset Content. /// Corresponds to HTTP status code 205 Reset Content.
/// </summary> /// </summary>
public static Result<T> ResetContent(T? value, List<string>? messages) { public static Result<T> ResetContent(T? value, List<string>? messages = null) {
return new Result<T>(value, true, messages ?? [], HttpStatusCode.ResetContent); return new Result<T>(value, true, messages ?? [], HttpStatusCode.ResetContent);
} }
@ -251,14 +251,14 @@ public partial class Result<T> : Result {
/// Returns a result indicating the request was successful and the server is delivering only part of the resource due to a range header sent by the client. /// Returns a result indicating the request was successful and the server is delivering only part of the resource due to a range header sent by the client.
/// Corresponds to HTTP status code 206 Partial Content. /// Corresponds to HTTP status code 206 Partial Content.
/// </summary> /// </summary>
public static Result<T> PartialContent(T? value, string? message) => public static Result<T> PartialContent(T? value, string? message = null) =>
PartialContent(value, message != null ? [message] : null); PartialContent(value, message != null ? [message] : null);
/// <summary> /// <summary>
/// Returns a result indicating the request was successful and the server is delivering only part of the resource due to a range header sent by the client. /// Returns a result indicating the request was successful and the server is delivering only part of the resource due to a range header sent by the client.
/// Corresponds to HTTP status code 206 Partial Content. /// Corresponds to HTTP status code 206 Partial Content.
/// </summary> /// </summary>
public static Result<T> PartialContent(T? value, List<string>? messages) { public static Result<T> PartialContent(T? value, List<string>? messages = null) {
return new Result<T>(value, true, messages ?? [], HttpStatusCode.PartialContent); return new Result<T>(value, true, messages ?? [], HttpStatusCode.PartialContent);
} }
@ -266,14 +266,14 @@ public partial class Result<T> : Result {
/// Returns a result indicating the request was successful and the response contains multiple status codes, typically used for WebDAV. /// Returns a result indicating the request was successful and the response contains multiple status codes, typically used for WebDAV.
/// Corresponds to HTTP status code 207 Multi-Status. /// Corresponds to HTTP status code 207 Multi-Status.
/// </summary> /// </summary>
public static Result<T> MultiStatus(T? value, string? message) => public static Result<T> MultiStatus(T? value, string? message = null) =>
MultiStatus(value, message != null ? [message] : null); MultiStatus(value, message != null ? [message] : null);
/// <summary> /// <summary>
/// Returns a result indicating the request was successful and the response contains multiple status codes, typically used for WebDAV. /// Returns a result indicating the request was successful and the response contains multiple status codes, typically used for WebDAV.
/// Corresponds to HTTP status code 207 Multi-Status. /// Corresponds to HTTP status code 207 Multi-Status.
/// </summary> /// </summary>
public static Result<T> MultiStatus(T? value, List<string>? messages) { public static Result<T> MultiStatus(T? value, List<string>? messages = null) {
return new Result<T>(value, true, messages ?? [], HttpStatusCode.MultiStatus); return new Result<T>(value, true, messages ?? [], HttpStatusCode.MultiStatus);
} }
@ -281,14 +281,14 @@ public partial class Result<T> : Result {
/// Returns a result indicating the request was successful and the information has already been reported in a previous response. /// Returns a result indicating the request was successful and the information has already been reported in a previous response.
/// Corresponds to HTTP status code 208 Already Reported. /// Corresponds to HTTP status code 208 Already Reported.
/// </summary> /// </summary>
public static Result<T> AlreadyReported(T? value, string? message) => public static Result<T> AlreadyReported(T? value, string? message = null) =>
AlreadyReported(value, message != null ? [message] : null); AlreadyReported(value, message != null ? [message] : null);
/// <summary> /// <summary>
/// Returns a result indicating the request was successful and the information has already been reported in a previous response. /// Returns a result indicating the request was successful and the information has already been reported in a previous response.
/// Corresponds to HTTP status code 208 Already Reported. /// Corresponds to HTTP status code 208 Already Reported.
/// </summary> /// </summary>
public static Result<T> AlreadyReported(T? value, List<string>? messages) { public static Result<T> AlreadyReported(T? value, List<string>? messages = null) {
return new Result<T>(value, true, messages ?? [], HttpStatusCode.AlreadyReported); return new Result<T>(value, true, messages ?? [], HttpStatusCode.AlreadyReported);
} }
@ -296,14 +296,14 @@ public partial class Result<T> : Result {
/// Returns a result indicating the request was successful and the server fulfilled the request for the resource using the delta encoding method. /// Returns a result indicating the request was successful and the server fulfilled the request for the resource using the delta encoding method.
/// Corresponds to HTTP status code 226 IM Used. /// Corresponds to HTTP status code 226 IM Used.
/// </summary> /// </summary>
public static Result<T> IMUsed(T? value, string? message) => public static Result<T> IMUsed(T? value, string? message = null) =>
IMUsed(value, message != null ? [message] : null); IMUsed(value, message != null ? [message] : null);
/// <summary> /// <summary>
/// Returns a result indicating the request was successful and the server fulfilled the request for the resource using the delta encoding method. /// Returns a result indicating the request was successful and the server fulfilled the request for the resource using the delta encoding method.
/// Corresponds to HTTP status code 226 IM Used. /// Corresponds to HTTP status code 226 IM Used.
/// </summary> /// </summary>
public static Result<T> IMUsed(T? value, List<string>? messages) { public static Result<T> IMUsed(T? value, List<string>? messages = null) {
return new Result<T>(value, true, messages ?? [], (HttpStatusCode)226); // 226 is the official status code for IM Used return new Result<T>(value, true, messages ?? [], (HttpStatusCode)226); // 226 is the official status code for IM Used
} }
} }