< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Runtime.ReflectionExtensions
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Runtime/ReflectionExtensions.cs
Line coverage
94%
Covered lines: 33
Uncovered lines: 2
Coverable lines: 35
Total lines: 101
Line coverage: 94.2%
Branch coverage
94%
Covered branches: 32
Total branches: 34
Branch coverage: 94.1%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
GetTypeCode(...)94.11%343494.28%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Runtime/ReflectionExtensions.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.Reflection;
 6
 7namespace CoreWCF.Runtime
 8{
 9    public static class ReflectionExtensions
 10    {
 11        public static TypeCode GetTypeCode(this Type type)
 12        {
 676413            if (type == null)
 14            {
 015                return TypeCode.Empty;
 16            }
 17
 676418            if (type == typeof(bool))
 19            {
 17920                return TypeCode.Boolean;
 21            }
 22
 658523            if (type == typeof(char))
 24            {
 225                return TypeCode.Char;
 26            }
 27
 658328            if (type == typeof(sbyte))
 29            {
 230                return TypeCode.SByte;
 31            }
 32
 658133            if (type == typeof(byte))
 34            {
 10835                return TypeCode.Byte;
 36            }
 37
 647338            if (type == typeof(short))
 39            {
 240                return TypeCode.Int16;
 41            }
 42
 647143            if (type == typeof(ushort))
 44            {
 245                return TypeCode.UInt16;
 46            }
 47
 646948            if (type == typeof(int))
 49            {
 24550                return TypeCode.Int32;
 51            }
 52
 622453            if (type == typeof(uint))
 54            {
 255                return TypeCode.UInt32;
 56            }
 57
 622258            if (type == typeof(long))
 59            {
 1060                return TypeCode.Int64;
 61            }
 62
 621263            if (type == typeof(ulong))
 64            {
 265                return TypeCode.UInt64;
 66            }
 67
 621068            if (type == typeof(float))
 69            {
 970                return TypeCode.Single;
 71            }
 72
 620173            if (type == typeof(double))
 74            {
 675                return TypeCode.Double;
 76            }
 77
 619578            if (type == typeof(decimal))
 79            {
 680                return TypeCode.Decimal;
 81            }
 82
 618983            if (type == typeof(DateTime))
 84            {
 685                return TypeCode.DateTime;
 86            }
 87
 618388            if (type == typeof(string))
 89            {
 542090                return TypeCode.String;
 91            }
 92
 76393            if (type.GetTypeInfo().IsEnum)
 94            {
 095                return GetTypeCode(Enum.GetUnderlyingType(type));
 96            }
 97
 76398            return TypeCode.Object;
 99        }
 100    }
 101}

Methods/Properties

GetTypeCode(System.Type)