< Summary

Information
Class: System.Net.Http.ReadOnlyMemoryContent
Assembly: System.Net.Http
File(s): D:\runner\runtime\src\libraries\System.Net.Http\src\System\Net\Http\ReadOnlyMemoryContent.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 15
Coverable lines: 15
Total lines: 45
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%110%
SerializeToStream(...)100%110%
SerializeToStreamAsync(...)100%110%
SerializeToStreamAsync(...)100%110%
TryComputeLength(...)100%110%
CreateContentReadStream(...)100%110%
CreateContentReadStreamAsync()100%110%
TryCreateContentReadStream()100%110%

File(s)

D:\runner\runtime\src\libraries\System.Net.Http\src\System\Net\Http\ReadOnlyMemoryContent.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
 4using System.IO;
 5using System.Threading;
 6using System.Threading.Tasks;
 7
 8namespace System.Net.Http
 9{
 10    public sealed class ReadOnlyMemoryContent : HttpContent
 11    {
 12        private readonly ReadOnlyMemory<byte> _content;
 13
 014        public ReadOnlyMemoryContent(ReadOnlyMemory<byte> content) =>
 015            _content = content;
 16
 17        protected override void SerializeToStream(Stream stream, TransportContext? context, CancellationToken cancellati
 018        {
 019            stream.Write(_content.Span);
 020        }
 21
 22        protected override Task SerializeToStreamAsync(Stream stream, TransportContext? context) =>
 023            stream.WriteAsync(_content).AsTask();
 24
 25        protected override Task SerializeToStreamAsync(Stream stream, TransportContext? context, CancellationToken cance
 026            stream.WriteAsync(_content, cancellationToken).AsTask();
 27
 28        protected internal override bool TryComputeLength(out long length)
 029        {
 030            length = _content.Length;
 031            return true;
 032        }
 33
 34        protected override Stream CreateContentReadStream(CancellationToken cancellationToken) =>
 035            new ReadOnlyMemoryStream(_content);
 36
 37        protected override Task<Stream> CreateContentReadStreamAsync() =>
 038            Task.FromResult<Stream>(new ReadOnlyMemoryStream(_content));
 39
 40        internal override Stream TryCreateContentReadStream() =>
 041            new ReadOnlyMemoryStream(_content);
 42
 043        internal override bool AllowDuplex => false;
 44    }
 45}