< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Description.MessageContractHelper
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Description/MessageContractHelper.cs
Line coverage
100%
Covered lines: 37
Uncovered lines: 0
Coverable lines: 37
Total lines: 80
Line coverage: 100%
Branch coverage
100%
Covered branches: 28
Total branches: 28
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
IsMessageContract(...)100%66100%
.cctor()100%11100%
IsEligibleMember(...)100%44100%
IsMessageHeader(...)100%1010100%
IsMessageProperty(...)100%88100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Description/MessageContractHelper.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 System.Reflection;
 7
 8namespace CoreWCF.Description
 9{
 10    // goal of this class to move logic from TypeLoader to build message contract
 11    internal static class MessageContractHelper
 12    {
 13        internal static bool IsMessageContract(Type type)
 14        {
 4183615            foreach (Attribute attr in type.GetCustomAttributes(inherit: false))
 16            {
 1683217                if (attr.GetType() == typeof(MessageContractAttribute)
 1683218                || (string.Compare(attr.GetType().FullName, ServiceReflector.SMMessageContractAttributeFullName, true) =
 19                {
 33220                    return true;
 21                }
 22            }
 392023            return false;
 24        }
 25
 426        private static HashSet<string> s_eligibleMessageList = new HashSet<string>()
 427            {
 428                ServiceReflector.CWCFMessageHeaderAttribute,
 429                ServiceReflector.CWCFMessageHeaderArrayAttribute,
 430                ServiceReflector.CWCFMessageBodyMemberAttribute,
 431                ServiceReflector.CWCFMessagePropertyAttribute,
 432                ServiceReflector.SMMessageHeaderAttributeFullName,
 433                ServiceReflector.SMMessageHeaderArrayAttributeFullName,
 434                ServiceReflector.SMMessageBodyMemberAttributeFullName,
 435                ServiceReflector.SMMessagePropertyAttributeFullName
 436            };
 37
 38        internal static bool IsEligibleMember(MemberInfo memberInfo)
 39        {
 114940            foreach (Attribute attr in memberInfo.GetCustomAttributes())
 41            {
 33642                if (s_eligibleMessageList.Contains(attr.GetType().FullName))
 43                {
 19544                    return true;
 45                }
 46            }
 14147            return false;
 19548        }
 49
 50        internal static bool IsMessageHeader(MemberInfo memberInfo)
 51        {
 69452            foreach (Attribute attr in memberInfo.GetCustomAttributes())
 53            {
 19554                if ((attr.GetType() == typeof(MessageHeaderAttribute))
 19555                    || (attr.GetType() == typeof(MessageHeaderArrayAttribute))
 19556                    || (string.Compare(attr.GetType().FullName, ServiceReflector.SMMessageHeaderAttributeFullName, true)
 19557                    || (string.Compare(attr.GetType().FullName, ServiceReflector.SMMessageHeaderArrayAttributeFullName, 
 19558                    )
 59                {
 8660                    return true;
 61                }
 62            }
 10963            return false;
 8664        }
 65
 66        internal static bool IsMessageProperty(MemberInfo memberInfo)
 67        {
 43168            foreach (Attribute attr in memberInfo.GetCustomAttributes())
 69            {
 10970                if (attr.GetType() == typeof(CoreWCF.MessagePropertyAttribute)
 10971                    || attr.GetType() == typeof(MessagePropertyAttribute)
 10972                    || string.Compare(attr.GetType().FullName, ServiceReflector.SMMessagePropertyAttributeFullName, true
 73                {
 574                    return true;
 75                }
 76            }
 10477            return false;
 578        }
 79    }
 80}