Skip to content

Commit 63aab6a

Browse files
committed
Fix implicit operator conversion, and define success property.
1 parent b9af4da commit 63aab6a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Initium/Results/ServiceResult.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ public ServiceResult WithMetadata(string key, string value)
129129
/// A <see cref="ServiceResult"/> instance representing the success or error state.
130130
/// </returns>
131131
public static implicit operator ServiceResult(bool isSuccess) => isSuccess ? Ok() : Error();
132-
133132
}
134133

135134
/// <summary>
@@ -205,8 +204,12 @@ public class ServiceResult<TData> : ServiceResult
205204
/// Implicitly converts data of type <typeparamref name="TData"/> into a <see cref="ServiceResult{TData}"/> representing a successful result.
206205
/// </summary>
207206
/// <param name="data">The data to wrap in a <see cref="ServiceResult{TData}"/>.</param>
208-
public static implicit operator ServiceResult<TData>(TData? data) => new() { Data = data };
209-
207+
public static implicit operator ServiceResult<TData>(TData? data) => new()
208+
{
209+
Success = true,
210+
Data = data
211+
};
212+
210213
/// <summary>
211214
/// Unwraps the data contained in the result, throwing an exception if the result is unsuccessful or the data is null.
212215
/// </summary>

0 commit comments

Comments
 (0)