< Summary

Class:SharpHoundRPC.Result<T>
Assembly:SharpHoundRPC
File(s):D:\a\SharpHoundCommon\SharpHoundCommon\src\SharpHoundRPC\Result.cs
Covered lines:26
Uncovered lines:4
Coverable lines:30
Total lines:55
Line coverage:86.6% (26 of 30)
Covered branches:1
Total branches:2
Branch coverage:50% (1 of 2)

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
Ok(...)100%10100%
Fail(...)100%10100%
Fail(...)100%10100%
op_Implicit(...)100%10100%
op_Implicit(...)100%10100%
op_Implicit(...)100%100%

File(s)

D:\a\SharpHoundCommon\SharpHoundCommon\src\SharpHoundRPC\Result.cs

#LineLine coverage
 1namespace SharpHoundRPC
 2{
 3    public class Result<T>
 4    {
 645        public bool IsSuccess { get; private set; }
 26        public NtStatus Status { get; private set; }
 647        public T Value { get; private set; }
 88        public string Error { get; private set; }
 309        public bool IsFailed => !IsSuccess;
 210        public bool IsTimeout { get; set; }
 11
 12        public static Result<T> Ok(T value)
 3113        {
 3114            return new() {IsSuccess = true, Value = value};
 3115        }
 16
 17        public static Result<T> Fail(NtStatus status)
 218        {
 219            return new() {Status = status};
 220        }
 21
 22        public static Result<T> Fail(string error)
 223        {
 224            return new() {Error = error};
 225        }
 26
 27        public string SError
 28        {
 29            get
 230            {
 231                if (!string.IsNullOrEmpty(Error))
 232                {
 233                    return Error;
 34                }
 35
 036                return Status.ToString();
 237            }
 38        }
 39
 40        public static implicit operator Result<T>(T input)
 2941        {
 2942            return Ok(input);
 2943        }
 44
 45        public static implicit operator Result<T>(NtStatus status)
 246        {
 247            return Fail(status);
 248        }
 49
 50        public static implicit operator Result<T>(string error)
 051        {
 052            return Fail(error);
 053        }
 54    }
 55}