< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Configuration.XmlDictionaryReaderQuotasElement
Assembly: CoreWCF.ConfigurationManager
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.ConfigurationManager/src/CoreWCF/Configuration/XmlDictionaryReaderQuotasElement.cs
Line coverage
41%
Covered lines: 16
Uncovered lines: 23
Coverable lines: 39
Total lines: 132
Line coverage: 41%
Branch coverage
29%
Covered branches: 7
Total branches: 24
Branch coverage: 29.1%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
ApplyConfiguration(...)58.33%121261.53%
Clone()100%11100%
InitializeFrom(...)0%12120%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.ConfigurationManager/src/CoreWCF/Configuration/XmlDictionaryReaderQuotasElement.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.Configuration;
 5using System.Xml;
 6using CoreWCF.Channels;
 7
 8namespace CoreWCF.Configuration
 9{
 10    public class XmlDictionaryReaderQuotasElement : ServiceModelConfigurationElement
 11    {
 12        // for all properties, a value of 0 means "just use the default"
 13        [ConfigurationProperty(ConfigurationStrings.MaxDepth, DefaultValue = 0)]
 14        [IntegerValidator(MinValue = 0)]
 15        public int MaxDepth
 16        {
 4217            get { return (int)base[ConfigurationStrings.MaxDepth]; }
 018            set { base[ConfigurationStrings.MaxDepth] = value; }
 19        }
 20
 21        [ConfigurationProperty(ConfigurationStrings.MaxStringContentLength, DefaultValue = 0)]
 22        [IntegerValidator(MinValue = 0)]
 23        public int MaxStringContentLength
 24        {
 2725            get { return (int)base[ConfigurationStrings.MaxStringContentLength]; }
 026            set { base[ConfigurationStrings.MaxStringContentLength] = value; }
 27        }
 28
 29        [ConfigurationProperty(ConfigurationStrings.MaxArrayLength, DefaultValue = 0)]
 30        [IntegerValidator(MinValue = 0)]
 31        public int MaxArrayLength
 32        {
 2733            get { return (int)base[ConfigurationStrings.MaxArrayLength]; }
 034            set { base[ConfigurationStrings.MaxArrayLength] = value; }
 35        }
 36
 37        [ConfigurationProperty(ConfigurationStrings.MaxBytesPerRead, DefaultValue = 0)]
 38        [IntegerValidator(MinValue = 0)]
 39        public int MaxBytesPerRead
 40        {
 2741            get { return (int)base[ConfigurationStrings.MaxBytesPerRead]; }
 042            set { base[ConfigurationStrings.MaxBytesPerRead] = value; }
 43        }
 44
 45        [ConfigurationProperty(ConfigurationStrings.MaxNameTableCharCount, DefaultValue = 0)]
 46        [IntegerValidator(MinValue = 0)]
 47        public int MaxNameTableCharCount
 48        {
 2749            get { return (int)base[ConfigurationStrings.MaxNameTableCharCount]; }
 050            set { base[ConfigurationStrings.MaxNameTableCharCount] = value; }
 51        }
 52
 53        internal void ApplyConfiguration(XmlDictionaryReaderQuotas readerQuotas)
 54        {
 2755            if (readerQuotas == null)
 56            {
 057                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(readerQuotas));
 58            }
 2759            if (MaxDepth != 0)
 60            {
 1061                readerQuotas.MaxDepth = MaxDepth;
 62            }
 2763            if (MaxStringContentLength != 0)
 64            {
 065                readerQuotas.MaxStringContentLength = MaxStringContentLength;
 66            }
 2767            if (MaxArrayLength != 0)
 68            {
 069                readerQuotas.MaxArrayLength = MaxArrayLength;
 70            }
 2771            if (MaxBytesPerRead != 0)
 72            {
 073                readerQuotas.MaxBytesPerRead = MaxBytesPerRead;
 74            }
 2775            if (MaxNameTableCharCount != 0)
 76            {
 077                readerQuotas.MaxNameTableCharCount = MaxNameTableCharCount;
 78            }
 2779        }
 80
 81        internal XmlDictionaryReaderQuotas Clone()
 82        {
 1983            var readerQuotas = new XmlDictionaryReaderQuotas();
 1984            ApplyConfiguration(readerQuotas);
 1985            return readerQuotas;
 86        }
 87
 88        internal void InitializeFrom(XmlDictionaryReaderQuotas readerQuotas)
 89        {
 090            if (readerQuotas == null)
 91            {
 092                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(readerQuotas));
 93            }
 094            if (readerQuotas.MaxDepth != EncoderDefaults.MaxDepth)
 95            {
 096                SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxDepth, readerQuotas.MaxDepth);
 97            }
 098            if (readerQuotas.MaxStringContentLength != EncoderDefaults.MaxStringContentLength)
 99            {
 0100                SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxStringContentLength, readerQuotas.MaxStringCon
 101            }
 0102            if (readerQuotas.MaxArrayLength != EncoderDefaults.MaxArrayLength)
 103            {
 0104                SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxArrayLength, readerQuotas.MaxArrayLength);
 105            }
 0106            if (readerQuotas.MaxBytesPerRead != EncoderDefaults.MaxBytesPerRead)
 107            {
 0108                SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxBytesPerRead, readerQuotas.MaxBytesPerRead);
 109            }
 0110            if (readerQuotas.MaxNameTableCharCount != EncoderDefaults.MaxNameTableCharCount)
 111            {
 0112                SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxNameTableCharCount, readerQuotas.MaxNameTableC
 113            }
 0114        }
 115    }
 116
 117    internal static class EncoderDefaults
 118    {
 119        internal const int MaxReadPoolSize = 64;
 120        internal const int MaxWritePoolSize = 16;
 121
 122        internal const CompressionFormat DefaultCompressionFormat = CompressionFormat.None;
 123
 124        internal const int MaxDepth = 32;
 125        internal const int MaxStringContentLength = 8192;
 126        internal const int MaxArrayLength = 16384;
 127        internal const int MaxBytesPerRead = 4096;
 128        internal const int MaxNameTableCharCount = 16384;
 129
 130    }
 131
 132}