< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Channels.WebMessageEncodingBindingElement
Assembly: CoreWCF.WebHttp
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.WebHttp/src/CoreWCF/Channels/WebMessageEncodingBindingElement.cs
Line coverage
68%
Covered lines: 40
Uncovered lines: 18
Coverable lines: 58
Total lines: 175
Line coverage: 68.9%
Branch coverage
37%
Covered branches: 6
Total branches: 16
Branch coverage: 37.5%
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(...)50%2290%
.ctor(...)100%11100%
Clone()100%11100%
CreateMessageEncoderFactory()100%11100%
GetProperty(...)50%4460%
CheckEncodingVersion(...)100%110%
IsMatch(...)100%110%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.WebHttp/src/CoreWCF/Channels/WebMessageEncodingBindingElement.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.Text;
 6using System.Xml;
 7
 8namespace CoreWCF.Channels
 9{
 10    public sealed class WebMessageEncodingBindingElement : MessageEncodingBindingElement//, IWsdlExportExtension
 11    {
 12        private int _maxReadPoolSize;
 13        private int _maxWritePoolSize;
 14        private Encoding _writeEncoding;
 15
 4216        public WebMessageEncodingBindingElement() : this(TextEncoderDefaults.Encoding)
 17        {
 4218        }
 19
 4220        public WebMessageEncodingBindingElement(Encoding writeEncoding)
 21        {
 4222            if (writeEncoding == null)
 23            {
 024                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(writeEncoding));
 25            }
 26
 4227            TextEncoderDefaults.ValidateEncoding(writeEncoding);
 4228            _maxReadPoolSize = EncoderDefaults.MaxReadPoolSize;
 4229            _maxWritePoolSize = EncoderDefaults.MaxWritePoolSize;
 4230            ReaderQuotas = new XmlDictionaryReaderQuotas();
 4231            EncoderDefaults.ReaderQuotas.CopyTo(ReaderQuotas);
 4232            _writeEncoding = writeEncoding;
 4233        }
 34
 35        private WebMessageEncodingBindingElement(WebMessageEncodingBindingElement elementToBeCloned)
 84936            : base(elementToBeCloned)
 37        {
 84938            _maxReadPoolSize = elementToBeCloned._maxReadPoolSize;
 84939            _maxWritePoolSize = elementToBeCloned._maxWritePoolSize;
 84940            ReaderQuotas = new XmlDictionaryReaderQuotas();
 84941            elementToBeCloned.ReaderQuotas.CopyTo(ReaderQuotas);
 84942            _writeEncoding = elementToBeCloned._writeEncoding;
 84943            ContentTypeMapper = elementToBeCloned.ContentTypeMapper;
 84944            CrossDomainScriptAccessEnabled = elementToBeCloned.CrossDomainScriptAccessEnabled;
 84945        }
 46
 181447        public WebContentTypeMapper ContentTypeMapper { get; set; }
 48
 49        public int MaxReadPoolSize
 50        {
 51            get
 52            {
 4053                return _maxReadPoolSize;
 54            }
 55            set
 56            {
 057                if (value <= 0)
 58                {
 059                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 060                        SR.Format(SRCommon.ValueMustBePositive)));
 61                }
 62
 063                _maxReadPoolSize = value;
 064            }
 65        }
 66
 67        public int MaxWritePoolSize
 68        {
 69            get
 70            {
 4071                return _maxWritePoolSize;
 72            }
 73            set
 74            {
 075                if (value <= 0)
 76                {
 077                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 078                        SR.Format(SRCommon.ValueMustBePositive)));
 79                }
 80
 081                _maxWritePoolSize = value;
 082            }
 83        }
 84
 85        public override MessageVersion MessageVersion
 86        {
 87            get
 88            {
 22089                return MessageVersion.None;
 90            }
 91            set
 92            {
 3993                if (value == null)
 94                {
 095                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value));
 96                }
 97
 3998                if (value != MessageVersion.None)
 99                {
 0100                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(nameof(value), SR.Format(SR.JsonOnlySup
 101                }
 39102            }
 103        }
 104
 1784105        public XmlDictionaryReaderQuotas ReaderQuotas { get; }
 106
 107        public Encoding WriteEncoding
 108        {
 109            get
 110            {
 114111                return  _writeEncoding;
 112            }
 113            set
 114            {
 2115                if (value == null)
 116                {
 0117                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value));
 118                }
 119
 2120                TextEncoderDefaults.ValidateEncoding(value);
 2121                _writeEncoding = value;
 2122            }
 123        }
 124
 125        public bool CrossDomainScriptAccessEnabled
 126        {
 926127            get;
 849128            set;
 129        }
 130
 131        public override BindingElement Clone()
 132        {
 849133            return new WebMessageEncodingBindingElement(this);
 134        }
 135
 136        public override MessageEncoderFactory CreateMessageEncoderFactory()
 137        {
 40138            return new WebMessageEncoderFactory(WriteEncoding, MaxReadPoolSize, MaxWritePoolSize, ReaderQuotas, ContentT
 139        }
 140
 141        public override T GetProperty<T>(BindingContext context)
 142        {
 331143            if (context == null)
 144            {
 0145                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(context));
 146            }
 331147            if (typeof(T) == typeof(XmlDictionaryReaderQuotas))
 148            {
 0149                return (T)(object)ReaderQuotas;
 150            }
 151            else
 152            {
 331153                return base.GetProperty<T>(context);
 154            }
 155        }
 156
 157        //void IWsdlExportExtension.ExportContract(WsdlExporter exporter, WsdlContractConversionContext context)
 158        //{
 159        //}
 160
 161        //void IWsdlExportExtension.ExportEndpoint(WsdlExporter exporter, WsdlEndpointConversionContext context)
 162        //{
 163        //    if (context == null)
 164        //    {
 165        //        throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
 166        //    }
 167
 168        //    SoapHelper.SetSoapVersion(context, exporter, this.MessageVersion.Envelope);
 169        //}
 170
 0171        protected override bool CheckEncodingVersion(EnvelopeVersion version) => MessageVersion.Envelope == version;
 172
 0173        protected override bool IsMatch(BindingElement b) => false;
 174    }
 175}