< Summary

Information
Class: System.Net.Http.Headers.MediaTypeWithQualityHeaderValue
Assembly: System.Net.Http
File(s): D:\runner\runtime\src\libraries\System.Net.Http\src\System\Net\Http\Headers\MediaTypeWithQualityHeaderValue.cs
Line coverage
9%
Covered lines: 3
Uncovered lines: 29
Coverable lines: 32
Total lines: 65
Line coverage: 9.3%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor()100%11100%
.ctor(...)100%110%
.ctor(...)100%110%
.ctor(...)100%110%
System.ICloneable.Clone()100%110%
Parse(...)100%110%
TryParse(...)0%220%

File(s)

D:\runner\runtime\src\libraries\System.Net.Http\src\System\Net\Http\Headers\MediaTypeWithQualityHeaderValue.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;
 5using System.Diagnostics.CodeAnalysis;
 6
 7namespace System.Net.Http.Headers
 8{
 9    public sealed class MediaTypeWithQualityHeaderValue : MediaTypeHeaderValue, ICloneable
 10    {
 11        public double? Quality
 12        {
 013            get => HeaderUtilities.GetQuality((UnvalidatedObjectCollection<NameValueHeaderValue>)Parameters);
 014            set => HeaderUtilities.SetQuality((UnvalidatedObjectCollection<NameValueHeaderValue>)Parameters, value);
 15        }
 16
 17        internal MediaTypeWithQualityHeaderValue()
 384918            : base()
 384919        {
 20            // Used by the parser to create a new instance of this type.
 384921        }
 22
 23        public MediaTypeWithQualityHeaderValue(string mediaType)
 024            : base(mediaType)
 025        {
 026        }
 27
 28        public MediaTypeWithQualityHeaderValue(string mediaType, double quality)
 029            : base(mediaType)
 030        {
 031            Quality = quality;
 032        }
 33
 34        private MediaTypeWithQualityHeaderValue(MediaTypeWithQualityHeaderValue source)
 035            : base(source)
 036        {
 37            // No additional members to initialize here. This constructor is used by Clone().
 038        }
 39
 40        object ICloneable.Clone()
 041        {
 042            return new MediaTypeWithQualityHeaderValue(this);
 043        }
 44
 45        public static new MediaTypeWithQualityHeaderValue Parse(string input)
 046        {
 047            int index = 0;
 048            return (MediaTypeWithQualityHeaderValue)MediaTypeHeaderParser.SingleValueWithQualityParser.ParseValue(
 049                input, null, ref index);
 050        }
 51
 52        public static bool TryParse([NotNullWhen(true)] string? input, [NotNullWhen(true)] out MediaTypeWithQualityHeade
 053        {
 054            int index = 0;
 055            parsedValue = null;
 56
 057            if (MediaTypeHeaderParser.SingleValueWithQualityParser.TryParseValue(input, null, ref index, out object? out
 058            {
 059                parsedValue = (MediaTypeWithQualityHeaderValue)output!;
 060                return true;
 61            }
 062            return false;
 063        }
 64    }
 65}