< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.DataContractHelpers
Assembly: CoreWCF.WebHttp
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.WebHttp/src/CoreWCF/DataContractHelpers.cs
Line coverage
69%
Covered lines: 9
Uncovered lines: 4
Coverable lines: 13
Total lines: 38
Line coverage: 69.2%
Branch coverage
50%
Covered branches: 3
Total branches: 6
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.cctor()100%11100%
GetSubstituteDataContractType(...)50%6655.55%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.WebHttp/src/CoreWCF/DataContractHelpers.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;
 6using System.Collections.Generic;
 7using System.Linq;
 8using System.Reflection;
 9
 10namespace CoreWCF
 11{
 12    internal static class DataContractHelpers
 13    {
 114        private static readonly Type s_typeOfIQueryable = typeof(IQueryable);
 115        private static readonly Type s_typeOfIQueryableGeneric = typeof(IQueryable<>);
 116        private static readonly Type s_typeOfIEnumerable = typeof(IEnumerable);
 117        private static readonly Type s_typeOfIEnumerableGeneric = typeof(IEnumerable<>);
 18
 19        internal static Type GetSubstituteDataContractType(Type type, out bool isQueryable)
 20        {
 27221            if (type == s_typeOfIQueryable)
 22            {
 023                isQueryable = true;
 024                return s_typeOfIEnumerable;
 25            }
 26
 27227            if (type.GetTypeInfo().IsGenericType &&
 27228                type.GetGenericTypeDefinition() == s_typeOfIQueryableGeneric)
 29            {
 030                isQueryable = true;
 031                return s_typeOfIEnumerableGeneric.MakeGenericType(type.GetGenericArguments());
 32            }
 33
 27234            isQueryable = false;
 27235            return type;
 36        }
 37    }
 38}