< Summary

Line coverage
91%
Covered lines: 31
Uncovered lines: 3
Coverable lines: 34
Total lines: 75
Line coverage: 91.1%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
File 1: .ctor(...)100%11100%
File 1: .ctor(...)100%22100%
File 2: Initialize(...)100%44100%

File(s)

D:\runner\runtime\src\libraries\System.Net.Http\src\System\Net\Http\Headers\KnownHeader.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;
 5using System.Text;
 6
 7namespace System.Net.Http.Headers
 8{
 9    internal sealed partial class KnownHeader
 10    {
 11        public KnownHeader(string name, string[]? knownValues = null, int? http2StaticTableIndex = null, int? http3Stati
 3912            : this(name, HttpHeaderType.Custom, parser: null, knownValues, http2StaticTableIndex, http3StaticTableIndex)
 7813        { }
 14
 9815        public KnownHeader(string name, HttpHeaderType headerType, HttpHeaderParser? parser, string[]? knownValues = nul
 9816        {
 9817            Debug.Assert(!string.IsNullOrEmpty(name));
 9818            Debug.Assert(name[0] == ':' || HttpRuleParser.IsToken(name));
 19
 9820            Name = name;
 9821            HeaderType = headerType;
 9822            Parser = parser;
 9823            KnownValues = knownValues;
 24
 9825            Initialize(http2StaticTableIndex, http3StaticTableIndex);
 26
 9827            var asciiBytesWithColonSpace = new byte[name.Length + 2]; // + 2 for ':' and ' '
 9828            int asciiBytes = Encoding.ASCII.GetBytes(name, asciiBytesWithColonSpace);
 9829            Debug.Assert(asciiBytes == name.Length);
 9830            asciiBytesWithColonSpace[asciiBytesWithColonSpace.Length - 2] = (byte)':';
 9831            asciiBytesWithColonSpace[asciiBytesWithColonSpace.Length - 1] = (byte)' ';
 9832            AsciiBytesWithColonSpace = asciiBytesWithColonSpace;
 9833        }
 34
 35        partial void Initialize(int? http2StaticTableIndex, int? http3StaticTableIndex);
 36
 13296837        public string Name { get; }
 96476538        public HttpHeaderParser? Parser { get; }
 11036239        public HttpHeaderType HeaderType { get; }
 40
 41        /// <summary>
 42        /// If a raw string is a known value, this instance will be returned rather than allocating a new string.
 43        /// </summary>
 044        public string[]? KnownValues { get; }
 045        public byte[] AsciiBytesWithColonSpace { get; }
 046        public HeaderDescriptor Descriptor => new HeaderDescriptor(this);
 47    }
 48}

D:\runner\runtime\src\libraries\System.Net.Http\src\System\Net\Http\Headers\KnownHeader.Http2And3.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.CodeAnalysis;
 5using System.Net.Http.HPack;
 6
 7namespace System.Net.Http.Headers
 8{
 9    internal sealed partial class KnownHeader
 10    {
 11        [MemberNotNull(nameof(Http2EncodedName))]
 12        [MemberNotNull(nameof(Http3EncodedName))]
 13        partial void Initialize(int? http2StaticTableIndex, int? http3StaticTableIndex)
 9814        {
 9815            Http2EncodedName = http2StaticTableIndex.HasValue ?
 9816                HPackEncoder.EncodeLiteralHeaderFieldWithoutIndexingToAllocatedArray(http2StaticTableIndex.GetValueOrDef
 9817                HPackEncoder.EncodeLiteralHeaderFieldWithoutIndexingNewNameToAllocatedArray(Name);
 18
 9819            Http3EncodedName = http3StaticTableIndex.HasValue ?
 9820                QPack.QPackEncoder.EncodeLiteralHeaderFieldWithStaticNameReferenceToArray(http3StaticTableIndex.GetValue
 9821                QPack.QPackEncoder.EncodeLiteralHeaderFieldWithoutNameReferenceToArray(Name);
 9822        }
 23
 9824        public byte[] Http2EncodedName { get; private set; }
 9825        public byte[] Http3EncodedName { get; private set; }
 26    }
 27}