Summary

Class:System.Runtime.InteropServices.SequenceMarshal
Assembly:System.Memory
File(s):C:\GitHub\corefx\src\System.Memory\src\System\Runtime\InteropServices\SequenceMarshal.cs
Covered lines:12
Uncovered lines:0
Coverable lines:12
Total lines:63
Line coverage:100%

Metrics

MethodCyclomatic complexity NPath complexity Sequence coverage Branch coverage
TryGetReadOnlySequenceSegment(...)10100100
TryGetArray(...)10100100
TryGetOwnedMemory(...)10100100
TryGetReadOnlyMemory(...)10100100

File(s)

C:\GitHub\corefx\src\System.Memory\src\System\Runtime\InteropServices\SequenceMarshal.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.Buffers;
 6
 7namespace System.Runtime.InteropServices
 8{
 9    /// <summary>
 10    /// Provides a collection of methods for interoperating with <see cref="ReadOnlySequence{T}"/>
 11    /// </summary>
 12    public static partial class SequenceMarshal
 13    {
 14        /// <summary>
 15        /// Get <see cref="ReadOnlySequenceSegment{T}"/> from the underlying <see cref="ReadOnlySequence{T}"/>.
 16        /// If unable to get the <see cref="ReadOnlySequenceSegment{T}"/>, return false.
 17        /// </summary>
 18        public static bool TryGetReadOnlySequenceSegment<T>(ReadOnlySequence<T> sequence,
 19            out ReadOnlySequenceSegment<T> startSegment,
 20            out int startIndex,
 21            out ReadOnlySequenceSegment<T> endSegment,
 22            out int endIndex)
 123        {
 124            return sequence.TryGetReadOnlySequenceSegment(out startSegment, out startIndex, out endSegment, out endIndex
 125        }
 26
 27        /// <summary>
 28        /// Get an array segment from the underlying <see cref="ReadOnlySequence{T}"/>.
 29        /// If unable to get the array segment, return false with a default array segment.
 30        /// </summary>
 31        public static bool TryGetArray<T>(ReadOnlySequence<T> sequence, out ArraySegment<T> arraySegment)
 132        {
 133            return sequence.TryGetArray(out arraySegment);
 134        }
 35
 36        /// <summary>
 37        /// Get <see cref="OwnedMemory{T}"/> from the underlying <see cref="ReadOnlySequence{T}"/>.
 38        /// If unable to get the <see cref="OwnedMemory{T}"/>, return false.
 39        /// </summary>
 40        public static bool TryGetOwnedMemory<T>(ReadOnlySequence<T> sequence, out OwnedMemory<T> ownedMemory, out int st
 141        {
 142            return sequence.TryGetOwnedMemory(out ownedMemory, out start, out length);
 143        }
 44
 45        /// <summary>
 46        /// Get <see cref="ReadOnlyMemory{T}"/> from the underlying <see cref="ReadOnlySequence{T}"/>.
 47        /// If unable to get the <see cref="ReadOnlyMemory{T}"/>, return false.
 48        /// </summary>
 49        public static bool TryGetReadOnlyMemory<T>(ReadOnlySequence<T> sequence, out ReadOnlyMemory<T> readOnlyMemory)
 150        {
 151            return sequence.TryGetReadOnlyMemory(out readOnlyMemory);
 152        }
 53
 54        /// <summary>
 55        /// Get <see cref="string"/> from the underlying <see cref="ReadOnlySequence{T}"/>.
 56        /// If unable to get the <see cref="string"/>, return false.
 57        /// </summary>
 58        internal static bool TryGetString(ReadOnlySequence<char> sequence, out string text, out int start, out int lengt
 59        {
 60            return sequence.TryGetString(out text, out start, out length);
 61        }
 62    }
 63}