Summary

Class:System.SequencePosition
Assembly:System.Memory
File(s):C:\GitHub\corefx\src\System.Memory\src\System\SequencePosition.cs
Covered lines:11
Uncovered lines:0
Coverable lines:11
Total lines:61
Line coverage:100%
Branch coverage:100%

Metrics

MethodCyclomatic complexity NPath complexity Sequence coverage Branch coverage
.ctor(...)10100100
GetObject()10100100
GetInteger()10100100
op_Equality(...)20100100
op_Inequality(...)10100100
Equals(...)10100100
Equals(...)40100100
GetHashCode()32100100

File(s)

C:\GitHub\corefx\src\System.Memory\src\System\SequencePosition.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3// See the LICENSE file in the project root for more information.
 4
 5using System.Numerics.Hashing;
 6using System.ComponentModel;
 7
 8namespace System
 9{
 10    /// <summary>
 11    /// Represents position in non-contiguous set of memory.
 12    /// Properties of this type should not be interpreted by anything but the type that created it.
 13    /// </summary>
 14    public readonly struct SequencePosition : IEquatable<SequencePosition>
 15    {
 16        private readonly object _object;
 17        private readonly int _integer;
 18
 19        /// <summary>
 20        /// Creates new <see cref="SequencePosition"/>
 21        /// </summary>
 22        public SequencePosition(object @object, int integer)
 123        {
 124            _object = @object;
 125            _integer = integer;
 126        }
 27
 28        /// <summary>
 29        /// Returns object part of this <see cref="SequencePosition"/>
 30        /// </summary>
 31        [EditorBrowsable(EditorBrowsableState.Never)]
 132        public object GetObject() => _object;
 33
 34        /// <summary>
 35        /// Returns integer part of this <see cref="SequencePosition"/>
 36        /// </summary>
 37        [EditorBrowsable(EditorBrowsableState.Never)]
 138        public int GetInteger() => _integer;
 39
 40        /// <summary>
 41        /// Returns true if left and right point at the same segment and have the same index.
 42        /// </summary>
 143        public static bool operator ==(SequencePosition left, SequencePosition right) => left._integer== right._integer 
 44
 45        /// <summary>
 46        /// Returns true if left and right do not point at the same segment and have the same index.
 47        /// </summary>
 148        public static bool operator !=(SequencePosition left, SequencePosition right) => !(left == right);
 49
 50        /// <inheritdoc />
 151        public bool Equals(SequencePosition position) => this == position;
 52
 53        /// <inheritdoc />
 54        [EditorBrowsable(EditorBrowsableState.Never)]
 155        public override bool Equals(object obj) => obj is SequencePosition other && this == other;
 56
 57        /// <inheritdoc />
 58        [EditorBrowsable(EditorBrowsableState.Never)]
 159        public override int GetHashCode() => HashHelpers.Combine(_object?.GetHashCode() ?? 0, _integer);
 60    }
 61}