< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.EmptyArray<T>
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/EmptyArray.cs
Line coverage
100%
Covered lines: 11
Uncovered lines: 0
Coverable lines: 11
Total lines: 55
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
Allocate(...)100%22100%
ToArray(...)100%22100%
ToArray(...)100%11100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/EmptyArray.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.Collections.Generic;
 6using CoreWCF.Collections.Generic;
 7
 8namespace CoreWCF
 9{
 10    internal class EmptyArray<T>
 11    {
 12        internal static T[] Allocate(int n)
 13        {
 17814            if (n == 0)
 15            {
 15016                return Array.Empty<T>();
 17            }
 18
 2819            return new T[n];
 20        }
 21
 22        internal static T[] ToArray(ICollection<T> collection)
 23        {
 1065924            if (collection.Count == 0)
 25            {
 1057926                return Array.Empty<T>();
 27            }
 28
 8029            T[] array = new T[collection.Count];
 8030            collection.CopyTo(array, 0);
 8031            return array;
 32        }
 33
 34        internal static T[] ToArray(SynchronizedCollection<T> collection)
 35        {
 566136            lock (collection.SyncRoot)
 37            {
 566138                return ToArray((IList<T>)collection);
 39            }
 566140        }
 41    }
 42
 43    internal class EmptyArray
 44    {
 45        internal static object[] Allocate(int n)
 46        {
 47            if (n == 0)
 48            {
 49                return Array.Empty<object>();
 50            }
 51
 52            return new object[n];
 53        }
 54    }
 55}