< Summary

Information
Class: System.Net.Http.Http3Frame
Assembly: System.Net.Http
File(s): D:\runner\runtime\src\libraries\Common\src\System\Net\Http\aspnetcore\Http3\Frames\Http3Frame.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 27
Coverable lines: 27
Total lines: 61
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 8
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
TryReadIntegerPair(...)0%440%
TryWriteFrameEnvelope(...)0%440%

File(s)

D:\runner\runtime\src\libraries\Common\src\System\Net\Http\aspnetcore\Http3\Frames\Http3Frame.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.Diagnostics;
 5
 6namespace System.Net.Http
 7{
 8    internal static partial class Http3Frame
 9    {
 10        public const int MaximumEncodedFrameEnvelopeLength = 1 + VariableLengthIntegerHelper.MaximumEncodedLength; // Fr
 11
 12        /// <summary>
 13        /// Reads two variable-length integers.
 14        /// </summary>
 15        public static bool TryReadIntegerPair(ReadOnlySpan<byte> buffer, out long a, out long b, out int bytesRead)
 016        {
 017            if (VariableLengthIntegerHelper.TryRead(buffer, out a, out int aLength))
 018            {
 019                buffer = buffer.Slice(aLength);
 020                if (VariableLengthIntegerHelper.TryRead(buffer, out b, out int bLength))
 021                {
 022                    bytesRead = aLength + bLength;
 023                    return true;
 24                }
 025            }
 26
 027            b = 0;
 028            bytesRead = 0;
 029            return false;
 030        }
 31
 32        //  0                   1                   2                   3
 33        //  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
 34        // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 35        // |                           Type (i)                          ...
 36        // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 37        // |                          Length (i)                         ...
 38        // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 39        // |                       Frame Payload (*)                     ...
 40        // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 41        public static bool TryWriteFrameEnvelope(Http3FrameType frameType, long payloadLength, Span<byte> buffer, out in
 042        {
 043            Debug.Assert(VariableLengthIntegerHelper.GetByteCount((long)frameType) == 1, $"{nameof(TryWriteFrameEnvelope
 44
 045            if (buffer.Length != 0)
 046            {
 047                buffer[0] = (byte)frameType;
 048                buffer = buffer.Slice(1);
 49
 050                if (VariableLengthIntegerHelper.TryWrite(buffer, payloadLength, out int payloadLengthEncodedLength))
 051                {
 052                    bytesWritten = payloadLengthEncodedLength + 1;
 053                    return true;
 54                }
 055            }
 56
 057            bytesWritten = 0;
 058            return false;
 059        }
 60    }
 61}