< Summary

Information
Class: CounterpointCollective.Utilities.Either<T1, T2>
Assembly: Dataflow.Composable
File(s): /builds/counterpointcollective/composabledataflowblocks/Source/Dataflow.Composable/Utilities/Either.cs
Line coverage
93%
Covered lines: 14
Uncovered lines: 1
Coverable lines: 15
Total lines: 36
Line coverage: 93.3%
Branch coverage
50%
Covered branches: 2
Total branches: 4
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
get_FromLeft()50%22100%
get_FromRight()50%22100%
get_IsLeft()100%11100%
get_IsRight()100%11100%
.ctor(...)100%11100%
.ctor(...)100%11100%
Left(...)100%11100%
Right(...)100%11100%

File(s)

/builds/counterpointcollective/composabledataflowblocks/Source/Dataflow.Composable/Utilities/Either.cs

#LineLine coverage
 1using System;
 2
 3namespace CounterpointCollective.Utilities
 4{
 5    /// <exclude />
 06    public record Either<A, B>
 7    {
 8        private readonly A? _left;
 9        private readonly B? _right;
 10
 1011        public A FromLeft => IsLeft ? _left! : throw new InvalidOperationException("I am right");
 12
 1013        public B FromRight => IsRight ? _right! : throw new InvalidOperationException("I am left");
 14
 5015        public bool IsLeft { get; private init; }
 1016        public bool IsRight => !IsLeft;
 17
 1018        public Either(A left)
 19        {
 1020            _left = left;
 1021            IsLeft = true;
 1022        }
 23
 1024        public Either(B right)
 25        {
 1026            _right = right;
 1027            IsLeft = false;
 1028        }
 29
 30#pragma warning disable CA1000 // Do not declare static members on generic types
 1031        public static Either<A, B> Left(A left) => new(left);
 32
 1033        public static Either<A, B> Right(B right) => new(right);
 34#pragma warning restore CA1000 // Do not declare static members on generic types
 35    }
 36}