< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Channels.ByteStreamMessageUtility
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Channels/ByteStreamMessageUtility.cs
Line coverage
58%
Covered lines: 7
Uncovered lines: 5
Coverable lines: 12
Total lines: 50
Line coverage: 58.3%
Branch coverage
56%
Covered branches: 9
Total branches: 16
Branch coverage: 56.2%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
EnsureByteBoundaries(...)57.14%141454.54%
EnsureQuotas(...)50%22100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Channels/ByteStreamMessageUtility.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.Xml;
 5using CoreWCF.Runtime;
 6
 7namespace CoreWCF.Channels
 8{
 9    internal static class ByteStreamMessageUtility
 10    {
 11        public const string StreamElementName = "Binary";
 12        public const string XmlNamespace = "http://www.w3.org/XML/1998/namespace";
 13        public const string XmlNamespaceNamespace = "http://www.w3.org/2000/xmlns/";
 14
 15        // used when doing message tracing
 16        internal const string EncoderName = "ByteStreamMessageEncoder";
 17
 18        internal static void EnsureByteBoundaries(byte[] buffer, int index, int count, bool isRead)
 19        {
 1520            if (buffer == null)
 21            {
 022                throw Fx.Exception.ArgumentNull(nameof(buffer));
 23            }
 24
 1525            if (index < 0)
 26            {
 027                throw Fx.Exception.ArgumentOutOfRange(nameof(index), index, SR.Format(SR.ArgumentOutOfMinRange, 0));
 28            }
 29
 30            // we explicitly allow the case for index = 0, buffer.Length = 0 and count = 0 when it is write
 31            // Note that we rely on the last check of count > buffer.Length - index to cover count > 0 && index == buffe
 1532            if (index > buffer.Length || (isRead && index == buffer.Length))
 33            {
 034                throw Fx.Exception.ArgumentOutOfRange(nameof(index), index, SR.Format(SR.OffsetExceedsBufferSize, buffer
 35            }
 36
 1537            if (count < 0)
 38            {
 039                throw Fx.Exception.ArgumentOutOfRange(nameof(count), count, SR.Format(SR.ArgumentOutOfMinRange, 0));
 40            }
 41
 1542            if (count > buffer.Length - index)
 43            {
 044                throw Fx.Exception.ArgumentOutOfRange(nameof(count), count, SR.Format(SR.SizeExceedsRemainingBufferSpace
 45            }
 1546        }
 47
 1848        internal static XmlDictionaryReaderQuotas EnsureQuotas(XmlDictionaryReaderQuotas quotas) => quotas ?? EncoderDef
 49    }
 50}