From b6f4694ad2d397538d0c2685891f2cc24fdf0af1 Mon Sep 17 00:00:00 2001 From: Kyle Slusser Date: Sat, 13 Jul 2024 10:46:42 -0400 Subject: [PATCH 01/14] Add documentation comments for ResultExtensions --- .../Extensions/ResultExtensions.cs | 191 +++++++++++++++++- 1 file changed, 186 insertions(+), 5 deletions(-) diff --git a/src/FluentResults/Extensions/ResultExtensions.cs b/src/FluentResults/Extensions/ResultExtensions.cs index f11dfbe..23ed08a 100644 --- a/src/FluentResults/Extensions/ResultExtensions.cs +++ b/src/FluentResults/Extensions/ResultExtensions.cs @@ -3,73 +3,156 @@ namespace FluentResults.Extensions { + /// + /// Extension methods for Result + /// public static class ResultExtensions { + /// + /// Map all errors of the result via errorMapper + /// + /// The current result + /// Function to transform the errors public static async Task MapErrors(this Task resultTask, Func errorMapper) { var result = await resultTask; return result.MapErrors(errorMapper); } + /// + /// Map all errors of the result via errorMapper + /// + /// The current result + /// Function to transform the errors public static async ValueTask MapErrors(this ValueTask resultTask, Func errorMapper) { var result = await resultTask; return result.MapErrors(errorMapper); } + /// + /// Map all errors of the result via errorMapper + /// + /// The current result + /// Function to transform the errors public static async Task> MapErrors(this Task> resultTask, Func errorMapper) { var result = await resultTask; return result.MapErrors(errorMapper); } + /// + /// Map all errors of the result via errorMapper + /// + /// The current result + /// Function to transform the errors public static async ValueTask> MapErrors(this ValueTask> resultTask, Func errorMapper) { var result = await resultTask; return result.MapErrors(errorMapper); } + /// + /// Map all successes of the result via successMapper + /// + /// The current result + /// Function to transform the successes public static async Task MapSuccesses(this Task resultTask, Func errorMapper) { var result = await resultTask; return result.MapSuccesses(errorMapper); } + /// + /// Map all successes of the result via successMapper + /// + /// The current result + /// Function to transform the successes public static async ValueTask MapSuccesses(this ValueTask resultTask, Func errorMapper) { var result = await resultTask; return result.MapSuccesses(errorMapper); } + /// + /// Map all successes of the result via successMapper + /// The current result + /// Function to transform the successes + /// public static async Task> MapSuccesses(this Task> resultTask, Func errorMapper) { var result = await resultTask; return result.MapSuccesses(errorMapper); } + /// + /// Map all successes of the result via successMapper + /// + /// The current result + /// Function to transform the successes public static async ValueTask> MapSuccesses(this ValueTask> resultTask, Func errorMapper) { var result = await resultTask; return result.MapSuccesses(errorMapper); } + /// + /// Convert result with value to result with another value that may fail asynchronously. + /// + /// + /// + /// var bakeryDtoResult = await result.Bind(GetWhichMayFail); + /// + /// + /// The current result + /// Transformation that may fail. public static async Task> Bind(this Task> resultTask, Func>> bind) { var result = await resultTask; return await result.Bind(bind); } - + + /// + /// Convert result with value to result with another value that may fail asynchronously. + /// + /// + /// + /// var bakeryDtoResult = await result.Bind(GetWhichMayFail); + /// + /// + /// The current result + /// Transformation that may fail. public static async ValueTask> Bind(this ValueTask> resultTask, Func>> bind) { var result = await resultTask; return await result.Bind(bind); } + /// + /// Convert result with value to result with another value that may fail asynchronously. + /// + /// + /// + /// var bakeryDtoResult = await result.Bind(GetWhichMayFail); + /// + /// + /// The current result + /// Transformation that may fail. public static async Task> Bind(this Task> resultTask, Func> bind) { var result = await resultTask; return result.Bind(bind); } + /// + /// Convert result with value to result with another value that may fail asynchronously. + /// + /// + /// + /// var bakeryDtoResult = await result.Bind(GetWhichMayFail); + /// + /// + /// The current result + /// Transformation that may fail. public static async ValueTask> Bind(this ValueTask> resultTask, Func> bind) { @@ -77,72 +160,170 @@ public static async ValueTask> Bind(this ValueTask + /// Convert result with value to result with another value that may fail asynchronously. + /// + /// + /// + /// var bakeryDtoResult = await result.Bind(GetWhichMayFail); + /// + /// + /// The current result + /// Transformation that may fail. public static async Task Bind(this Task> resultTask, Func> bind) { var result = await resultTask; return await result.Bind(bind); } + /// + /// Convert result with value to result with another value that may fail asynchronously. + /// + /// + /// + /// var bakeryDtoResult = await result.Bind(GetWhichMayFail); + /// + /// + /// The current result + /// Transformation that may fail. public static async Task Bind(this Task> resultTask, Func bind) { var result = await resultTask; return result.Bind(bind); } + /// + /// Convert result with value to result with another value that may fail asynchronously. + /// + /// + /// + /// var bakeryDtoResult = await result.Bind(GetWhichMayFail); + /// + /// + /// The current result + /// Transformation that may fail. public static async ValueTask Bind(this ValueTask> resultTask, Func bind) { var result = await resultTask; return result.Bind(bind); } + /// + /// Convert result with value to result with another value that may fail asynchronously. + /// + /// + /// + /// var bakeryDtoResult = await result.Bind(GetWhichMayFail); + /// + /// + /// The current result + /// Transformation that may fail. public static async ValueTask Bind(this ValueTask> resultTask, Func> bind) { var result = await resultTask; return await result.Bind(bind); } - + + /// + /// Convert result with value to result with another value that may fail asynchronously. + /// + /// + /// + /// var bakeryDtoResult = await result.Bind(GetWhichMayFail); + /// + /// + /// The current result + /// Transformation that may fail. public static async Task> Bind(this Task resultTask, Func>> bind) { var result = await resultTask; return await result.Bind(bind); } - + + /// + /// Convert result with value to result with another value that may fail asynchronously. + /// + /// + /// + /// var bakeryDtoResult = await result.Bind(GetWhichMayFail); + /// + /// + /// The current result + /// Transformation that may fail. public static async ValueTask> Bind(this ValueTask resultTask, Func>> bind) { var result = await resultTask; return await result.Bind(bind); } - + + /// + /// Convert result with value to result with another value that may fail asynchronously. + /// + /// + /// + /// var bakeryDtoResult = await result.Bind(GetWhichMayFail); + /// + /// + /// The current result + /// Transformation that may fail. public static async Task Bind(this Task resultTask, Func> bind) { var result = await resultTask; return await result.Bind(bind); } - + + /// + /// Convert result with value to result with another value that may fail asynchronously. + /// + /// + /// + /// var bakeryDtoResult = await result.Bind(GetWhichMayFail); + /// + /// + /// The current result + /// Transformation that may fail. public static async ValueTask Bind(this ValueTask resultTask, Func> bind) { var result = await resultTask; return await result.Bind(bind); } + /// + /// Convert result with value to result with another value. Use valueConverter parameter to specify the value transformation logic. + /// public static async Task> Map(this Task> resultTask, Func valueConverter) { var result = await resultTask; return result.Map(valueConverter); } + /// + /// Convert result with value to result with another value. Use valueConverter parameter to specify the value transformation logic. + /// public static async Task> Map(this ValueTask> resultTask, Func valueConverter) { var result = await resultTask; return result.Map(valueConverter); } + /// + /// Convert result without value to a result containing a value + /// + /// Type of the value + /// The current result + /// Value to add to the new result public static async Task> ToResult(this Task resultTask, TValue value) { var result = await resultTask; return result.ToResult(value); } + /// + /// Convert result without value to a result containing a value + /// + /// Type of the value + /// The current result + /// Value to add to the new result public static async Task> ToResult(this ValueTask resultTask, TValue value) { var result = await resultTask; From f7020aec2772aee2190aab46bc99e8fe1e42ca0b Mon Sep 17 00:00:00 2001 From: Kyle Slusser Date: Sat, 13 Jul 2024 10:53:16 -0400 Subject: [PATCH 02/14] Add documentation comments for Result --- src/FluentResults/Results/Result.cs | 48 +++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/FluentResults/Results/Result.cs b/src/FluentResults/Results/Result.cs index c466ab4..0b03a0b 100644 --- a/src/FluentResults/Results/Result.cs +++ b/src/FluentResults/Results/Result.cs @@ -6,8 +6,14 @@ // ReSharper disable once CheckNamespace namespace FluentResults { + /// + /// Implementation of a Result + /// public partial class Result : ResultBase { + /// + /// Default constructor + /// public Result() { } @@ -38,6 +44,11 @@ public Result MapSuccesses(Func successMapper) .WithSuccesses(Successes.Select(successMapper)); } + /// + /// Convert result without value to a result containing a value + /// + /// Type of the value + /// Value to add to the new result public Result ToResult(TNewValue newValue = default) { return new Result() @@ -186,17 +197,29 @@ public async ValueTask Bind(Func> action) return result; } + /// + /// Implict conversion from to a + /// + /// The error public static implicit operator Result(Error error) { return Fail(error); } + /// + /// Implict conversion from to a + /// + /// The errors public static implicit operator Result(List errors) { return Fail(errors); } } + /// + /// Definition of a result with a value of type + /// + /// The type of the value public interface IResult : IResultBase { /// @@ -210,8 +233,15 @@ public interface IResult : IResultBase TValue ValueOrDefault { get; } } + /// + /// A result containing a value of type + /// + /// The type of the value public class Result : ResultBase>, IResult { + /// + /// Default constructor + /// public Result() { } @@ -452,6 +482,9 @@ public async ValueTask Bind(Func> action) return result; } + /// + /// ToString implementation + /// public override string ToString() { var baseString = base.ToString(); @@ -459,16 +492,25 @@ public override string ToString() return $"{baseString}, {valueString}"; } + /// + /// Implicit conversion from without a value to having the default value + /// public static implicit operator Result(Result result) { return result.ToResult(default); } + /// + /// Implicit conversion from having a value to without a value + /// public static implicit operator Result(Result result) { return result.ToResult(value => value); } + /// + /// Implicit conversion of a value to + /// public static implicit operator Result(TValue value) { if (value is Result r) @@ -477,11 +519,17 @@ public static implicit operator Result(TValue value) return Result.Ok(value); } + /// + /// Implicit conversion of an to + /// public static implicit operator Result(Error error) { return Result.Fail(error); } + /// + /// Implicit conversion of a list of to + /// public static implicit operator Result(List errors) { return Result.Fail(errors); From db99a322a5e23a7c27e66419a6d64f56ed767823 Mon Sep 17 00:00:00 2001 From: Kyle Slusser Date: Sat, 13 Jul 2024 11:02:13 -0400 Subject: [PATCH 03/14] Add documentation comments for EnumerableExtensions --- src/FluentResults/Extensions/EnumerableExtensions.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/FluentResults/Extensions/EnumerableExtensions.cs b/src/FluentResults/Extensions/EnumerableExtensions.cs index c041a7d..bd23435 100644 --- a/src/FluentResults/Extensions/EnumerableExtensions.cs +++ b/src/FluentResults/Extensions/EnumerableExtensions.cs @@ -3,6 +3,9 @@ // ReSharper disable once CheckNamespace namespace FluentResults { + /// + /// Helpful extensions for IEnumerable + /// public static class EnumerableExtensions { /// From 6014a8d0bb367dd8ddb94a2cb5e0170c539615f7 Mon Sep 17 00:00:00 2001 From: Kyle Slusser Date: Sat, 13 Jul 2024 11:02:02 -0400 Subject: [PATCH 04/14] Add documentation comments for Error --- src/FluentResults/Reasons/Error.cs | 6 ++++++ src/FluentResults/Reasons/IError.cs | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/FluentResults/Reasons/Error.cs b/src/FluentResults/Reasons/Error.cs index faca157..98d3294 100644 --- a/src/FluentResults/Reasons/Error.cs +++ b/src/FluentResults/Reasons/Error.cs @@ -25,6 +25,9 @@ public class Error : IError /// public List Reasons { get; } + /// + /// Creates a new instance of + /// protected Error() { Metadata = new Dictionary(); @@ -146,6 +149,9 @@ public Error WithMetadata(Dictionary metadata) return this; } + /// + /// ToString override + /// public override string ToString() { return new ReasonStringBuilder() diff --git a/src/FluentResults/Reasons/IError.cs b/src/FluentResults/Reasons/IError.cs index 958205c..e77cf1f 100644 --- a/src/FluentResults/Reasons/IError.cs +++ b/src/FluentResults/Reasons/IError.cs @@ -3,6 +3,9 @@ // ReSharper disable once CheckNamespace namespace FluentResults { + /// + /// Definition of an error + /// public interface IError : IReason { /// From ec1f53bf2c1205193a80c7279fbb2a364d7985f4 Mon Sep 17 00:00:00 2001 From: Kyle Slusser Date: Sat, 13 Jul 2024 11:10:14 -0400 Subject: [PATCH 05/14] Add documentation comments for Logging --- src/FluentResults/Logging/DefaultLogger.cs | 5 +++++ src/FluentResults/Logging/IResultLogger.cs | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/FluentResults/Logging/DefaultLogger.cs b/src/FluentResults/Logging/DefaultLogger.cs index 14c3bde..b149a2e 100644 --- a/src/FluentResults/Logging/DefaultLogger.cs +++ b/src/FluentResults/Logging/DefaultLogger.cs @@ -4,13 +4,18 @@ namespace FluentResults { + /// + /// Default implementation of that doesn't log anything + /// public class DefaultLogger : IResultLogger { + /// public void Log(string context, string content, ResultBase result, LogLevel logLevel) { } + /// public void Log(string content, ResultBase result, LogLevel logLevel) { diff --git a/src/FluentResults/Logging/IResultLogger.cs b/src/FluentResults/Logging/IResultLogger.cs index 377ecf6..b6f3a21 100644 --- a/src/FluentResults/Logging/IResultLogger.cs +++ b/src/FluentResults/Logging/IResultLogger.cs @@ -4,9 +4,27 @@ namespace FluentResults { + /// + /// Logging interface. Implement this if you want to have custom logging of results + /// public interface IResultLogger { + /// + /// Log result information + /// + /// Additional log context + /// Content to log + /// The result to log + /// The void Log(string context, string content, ResultBase result, LogLevel logLevel); + + /// + /// Log result information + /// + /// Additional log context + /// Content to log + /// The result to log + /// The void Log(string content, ResultBase result, LogLevel logLevel); } } \ No newline at end of file From f9dd0a74501a6645c3a28c68ad785d256e647d0c Mon Sep 17 00:00:00 2001 From: Kyle Slusser Date: Sat, 13 Jul 2024 11:15:03 -0400 Subject: [PATCH 06/14] Add documentation comments for ObjectExtensions --- src/FluentResults/Extensions/ObjectExtensions.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/FluentResults/Extensions/ObjectExtensions.cs b/src/FluentResults/Extensions/ObjectExtensions.cs index 3fa3a48..0828b7a 100644 --- a/src/FluentResults/Extensions/ObjectExtensions.cs +++ b/src/FluentResults/Extensions/ObjectExtensions.cs @@ -1,8 +1,16 @@ // ReSharper disable once CheckNamespace namespace FluentResults { + /// + /// Extension methods for object base type + /// public static class ObjectExtensions { + /// + /// Convert value to result + /// + /// The type of the result's + /// The value of the result public static Result ToResult(this TValue value) { return new Result() From 36ca72396b9d6f5d2cc1685c817850a490a66601 Mon Sep 17 00:00:00 2001 From: Kyle Slusser Date: Sat, 13 Jul 2024 11:20:49 -0400 Subject: [PATCH 07/14] Add documentation comments for ResultSettings --- src/FluentResults/Settings/ResultSettings.cs | 18 ++++++++++++++++++ .../Settings/ResultSettingsBuilder.cs | 16 ++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/FluentResults/Settings/ResultSettings.cs b/src/FluentResults/Settings/ResultSettings.cs index 7949d72..fe8ec94 100644 --- a/src/FluentResults/Settings/ResultSettings.cs +++ b/src/FluentResults/Settings/ResultSettings.cs @@ -3,16 +3,34 @@ // ReSharper disable once CheckNamespace namespace FluentResults { + /// + /// Settings for creating and handling result elements + /// public class ResultSettings { + /// + /// Set the ResultLogger + /// public IResultLogger Logger { get; set; } + /// + /// Factory to create an IError object. Used in all scenarios where an error is created within Try methods + /// public Func DefaultTryCatchHandler { get; set; } + /// + /// Factory to create an ISuccess object. Used in all scenarios where a success is created within FluentResults. + /// public Func SuccessFactory { get; set; } + /// + /// Factory to create an IError object. Used in all scenarios where an error is created within FluentResults. + /// public Func ErrorFactory { get; set; } + /// + /// Factory to create an IExceptionalError object. Used in all scenarios where an exceptional error is created within FluentResults. + /// public Func ExceptionalErrorFactory { get; set; } } } \ No newline at end of file diff --git a/src/FluentResults/Settings/ResultSettingsBuilder.cs b/src/FluentResults/Settings/ResultSettingsBuilder.cs index b5bcfac..30f6702 100644 --- a/src/FluentResults/Settings/ResultSettingsBuilder.cs +++ b/src/FluentResults/Settings/ResultSettingsBuilder.cs @@ -3,13 +3,19 @@ // ReSharper disable once CheckNamespace namespace FluentResults { + /// + /// Builder for + /// public class ResultSettingsBuilder { /// /// Set the ResultLogger /// public IResultLogger Logger { get; set; } - + + /// + /// Factory to create an IError object. Used in all scenarios where an error is created within Try methods + /// public Func DefaultTryCatchHandler { get; set; } /// @@ -27,7 +33,9 @@ public class ResultSettingsBuilder /// public Func ExceptionalErrorFactory { get; set; } - + /// + /// Default constructor that sets default values + /// public ResultSettingsBuilder() { // set defaults @@ -38,6 +46,10 @@ public ResultSettingsBuilder() ExceptionalErrorFactory = (errorMessage, exception) => new ExceptionalError(errorMessage ?? exception.Message, exception); } + /// + /// Create a object using the current values + /// + /// public ResultSettings Build() { return new ResultSettings From cd487ab20bcd3a54416e80431e4ce399f4ec43fd Mon Sep 17 00:00:00 2001 From: Kyle Slusser Date: Sat, 13 Jul 2024 11:22:53 -0400 Subject: [PATCH 08/14] Add documentation comments for IReason --- src/FluentResults/Reasons/IReason.cs | 9 +++++++++ src/FluentResults/Reasons/ISuccess.cs | 3 +++ 2 files changed, 12 insertions(+) diff --git a/src/FluentResults/Reasons/IReason.cs b/src/FluentResults/Reasons/IReason.cs index 2f033a6..9759e7e 100644 --- a/src/FluentResults/Reasons/IReason.cs +++ b/src/FluentResults/Reasons/IReason.cs @@ -3,10 +3,19 @@ // ReSharper disable once CheckNamespace namespace FluentResults { + /// + /// Definition of a reason. This is also the base of ISuccess and IError + /// public interface IReason { + /// + /// The reason's message + /// string Message { get; } + /// + /// Any metadata added to the reason + /// Dictionary Metadata { get; } } } \ No newline at end of file diff --git a/src/FluentResults/Reasons/ISuccess.cs b/src/FluentResults/Reasons/ISuccess.cs index d7ad314..437616b 100644 --- a/src/FluentResults/Reasons/ISuccess.cs +++ b/src/FluentResults/Reasons/ISuccess.cs @@ -1,6 +1,9 @@ // ReSharper disable once CheckNamespace namespace FluentResults { + /// + /// Definition of a success + /// public interface ISuccess : IReason { } } \ No newline at end of file From ad97e408263800db2c519c120f81c733628cbec8 Mon Sep 17 00:00:00 2001 From: Kyle Slusser Date: Sat, 13 Jul 2024 11:24:18 -0400 Subject: [PATCH 09/14] Add documentation comments for Success --- src/FluentResults/Reasons/Success.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/FluentResults/Reasons/Success.cs b/src/FluentResults/Reasons/Success.cs index 6a182d3..b4a51dc 100644 --- a/src/FluentResults/Reasons/Success.cs +++ b/src/FluentResults/Reasons/Success.cs @@ -18,11 +18,18 @@ public class Success : ISuccess /// public Dictionary Metadata { get; } + /// + /// Default constructor + /// protected Success() { Metadata = new Dictionary(); } + /// + /// Creates a new instance of and initializes the property + /// + /// The message public Success(string message) : this() { Message = message; @@ -50,6 +57,10 @@ public Success WithMetadata(Dictionary metadata) return this; } + /// + /// ToString override + /// + /// public override string ToString() { return new ReasonStringBuilder() From fe68ac1aad390a636a0c66c39fdaa46e5211f7e4 Mon Sep 17 00:00:00 2001 From: Kyle Slusser Date: Sat, 13 Jul 2024 11:32:10 -0400 Subject: [PATCH 10/14] Add documentation comments for ResultBase --- src/FluentResults/Results/ResultBase.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/FluentResults/Results/ResultBase.cs b/src/FluentResults/Results/ResultBase.cs index e0b23df..00ae293 100644 --- a/src/FluentResults/Results/ResultBase.cs +++ b/src/FluentResults/Results/ResultBase.cs @@ -6,6 +6,9 @@ // ReSharper disable once CheckNamespace namespace FluentResults { + /// + /// Definition of a ResultBase + /// public interface IResultBase { /// @@ -34,6 +37,9 @@ public interface IResultBase List Successes { get; } } + /// + /// Default implementation of + /// public abstract class ResultBase : IResultBase { /// @@ -61,6 +67,9 @@ public abstract class ResultBase : IResultBase /// public List Successes => Reasons.OfType().ToList(); + /// + /// Default constructor + /// protected ResultBase() { Reasons = new List(); @@ -230,6 +239,9 @@ public void Deconstruct(out bool isSuccess, out bool isFailed, out List } } + /// + /// Default implementation of generics + /// public abstract class ResultBase : ResultBase where TResult : ResultBase @@ -318,6 +330,9 @@ public TResult WithSuccess() return WithSuccess(new TSuccess()); } + /// + /// Add multiple successes + /// public TResult WithSuccesses(IEnumerable successes) { foreach (var success in successes) @@ -442,6 +457,10 @@ public TResult LogIfFailed(string content = null, LogLevel logLevel = return (TResult)this; } + /// + /// ToString override + /// + /// public override string ToString() { var reasonsString = Reasons.Any() From 6cdbe4931291d4e7b2fe861df21df2610e0a2e09 Mon Sep 17 00:00:00 2001 From: Kyle Slusser Date: Sat, 13 Jul 2024 13:30:28 -0400 Subject: [PATCH 11/14] Add documentation comments to ExceptionalEror --- src/FluentResults/Reasons/ExceptionalError.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/FluentResults/Reasons/ExceptionalError.cs b/src/FluentResults/Reasons/ExceptionalError.cs index 3db4e14..dd63174 100644 --- a/src/FluentResults/Reasons/ExceptionalError.cs +++ b/src/FluentResults/Reasons/ExceptionalError.cs @@ -13,16 +13,29 @@ public class ExceptionalError : Error, IExceptionalError /// public Exception Exception { get; } + + /// + /// Initialize a new instance with an exception + /// + /// The exception public ExceptionalError(Exception exception) : this(exception.Message, exception) { } + /// + /// Initialize a new instance with a custom message and an exception + /// + /// The message + /// The exception public ExceptionalError(string message, Exception exception) : base(message) { Exception = exception; } + /// + /// ToString override + /// public override string ToString() { return new ReasonStringBuilder() From 3bc95d93c9fce750416be4fc26902950ca18a2db Mon Sep 17 00:00:00 2001 From: Kyle Slusser Date: Sat, 13 Jul 2024 13:31:13 -0400 Subject: [PATCH 12/14] Add documentation comments for IExceptionalError --- src/FluentResults/Reasons/IExceptionalError.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/FluentResults/Reasons/IExceptionalError.cs b/src/FluentResults/Reasons/IExceptionalError.cs index 1a9a032..e46e946 100644 --- a/src/FluentResults/Reasons/IExceptionalError.cs +++ b/src/FluentResults/Reasons/IExceptionalError.cs @@ -3,8 +3,14 @@ // ReSharper disable once CheckNamespace namespace FluentResults { + /// + /// Definition of an error containing an exception + /// public interface IExceptionalError : IError { + /// + /// The exception + /// Exception Exception { get; } } From c6cfece6d2ee03b26211fa9c6f56265eaba2ac0b Mon Sep 17 00:00:00 2001 From: Kyle Slusser Date: Sat, 13 Jul 2024 13:33:27 -0400 Subject: [PATCH 13/14] Add documentation comments for ReasonExtensions --- src/FluentResults/Reasons/ReasonExtensions.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/FluentResults/Reasons/ReasonExtensions.cs b/src/FluentResults/Reasons/ReasonExtensions.cs index 8494b0f..f13d5db 100644 --- a/src/FluentResults/Reasons/ReasonExtensions.cs +++ b/src/FluentResults/Reasons/ReasonExtensions.cs @@ -3,8 +3,18 @@ // ReSharper disable once CheckNamespace namespace FluentResults { + /// + /// Extensions for + /// public static class ReasonExtensions { + /// + /// Check if a metadata key exists + /// + /// The reason instance + /// The metadata key + /// True if the metadata key exists + /// public static bool HasMetadataKey(this IReason reason, string key) { if(string.IsNullOrEmpty(key)) @@ -13,6 +23,14 @@ public static bool HasMetadataKey(this IReason reason, string key) return reason.Metadata.ContainsKey(key); } + /// + /// Check if a metadata key exists and matches the supplied predicate + /// + /// The reason instance + /// The metadata key + /// The predicate to check if the metadata key exists + /// True if the metadata value matches the predicate + /// public static bool HasMetadata(this IReason reason, string key, Func predicate) { if (string.IsNullOrEmpty(key)) From 245339c5e03df3c6e0a6ae84422718cdd9e99a22 Mon Sep 17 00:00:00 2001 From: Kyle Slusser Date: Sat, 13 Jul 2024 13:36:04 -0400 Subject: [PATCH 14/14] Add documentation comments for ReasonStringBuilder --- .../Reasons/ReasonStringBuilder.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/FluentResults/Reasons/ReasonStringBuilder.cs b/src/FluentResults/Reasons/ReasonStringBuilder.cs index 2219be0..608b2da 100644 --- a/src/FluentResults/Reasons/ReasonStringBuilder.cs +++ b/src/FluentResults/Reasons/ReasonStringBuilder.cs @@ -5,17 +5,31 @@ // ReSharper disable once CheckNamespace namespace FluentResults { + /// + /// Creates the text to dispay when serializing reason instances + /// public class ReasonStringBuilder { private string _reasonType = string.Empty; private readonly List _infos = new List(); + /// + /// Specify the type of reason + /// + /// The type of reason + /// Reference to the current Builder public ReasonStringBuilder WithReasonType(Type type) { _reasonType = type.Name; return this; } + /// + /// Add an information label for the given value + /// + /// The label to display + /// The value the label is for + /// A reference to the current Builder public ReasonStringBuilder WithInfo(string label, string value) { var infoString = value.ToLabelValueStringOrEmpty(label); @@ -28,6 +42,10 @@ public ReasonStringBuilder WithInfo(string label, string value) return this; } + /// + /// Create the reason string from the current information + /// + /// The reason string public string Build() { var reasonInfoText = _infos.Any()