< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.EmptyArray
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/EmptyArray.cs
Line coverage
100%
Covered lines: 3
Uncovered lines: 0
Coverable lines: 3
Total lines: 55
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
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%

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        {
 14            if (n == 0)
 15            {
 16                return Array.Empty<T>();
 17            }
 18
 19            return new T[n];
 20        }
 21
 22        internal static T[] ToArray(ICollection<T> collection)
 23        {
 24            if (collection.Count == 0)
 25            {
 26                return Array.Empty<T>();
 27            }
 28
 29            T[] array = new T[collection.Count];
 30            collection.CopyTo(array, 0);
 31            return array;
 32        }
 33
 34        internal static T[] ToArray(SynchronizedCollection<T> collection)
 35        {
 36            lock (collection.SyncRoot)
 37            {
 38                return ToArray((IList<T>)collection);
 39            }
 40        }
 41    }
 42
 43    internal class EmptyArray
 44    {
 45        internal static object[] Allocate(int n)
 46        {
 253947            if (n == 0)
 48            {
 252449                return Array.Empty<object>();
 50            }
 51
 1552            return new object[n];
 53        }
 54    }
 55}

Methods/Properties

Allocate(System.Int32)