< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Description.OperationDescription
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Description/OperationDescription.cs
Line coverage
80%
Covered lines: 45
Uncovered lines: 11
Coverable lines: 56
Total lines: 168
Line coverage: 80.3%
Branch coverage
56%
Covered branches: 9
Total branches: 16
Branch coverage: 56.2%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)50%6681.25%
.ctor(...)100%110%
IsServerInitiated()100%11100%
EnsureInvariants()75%4466.66%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Description/OperationDescription.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.Concurrent;
 6using System.Collections.Generic;
 7using System.Collections.ObjectModel;
 8using System.Reflection;
 9using CoreWCF.Collections.Generic;
 10using CoreWCF.Runtime.Collections;
 11using Microsoft.AspNetCore.Authorization;
 12
 13namespace CoreWCF.Description
 14{
 15    public class OperationDescription
 16    {
 17        internal const string SessionOpenedAction = "http://schemas.microsoft.com/2011/02/session/onopen"; //Channels.We
 18        private ContractDescription _declaringContract;
 19        private bool _hasNoDisposableParameters;
 20
 269221        public OperationDescription(string name, ContractDescription declaringContract)
 22        {
 269223            if (name == null)
 24            {
 025                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(name));
 26            }
 27
 269228            if (name.Length == 0)
 29            {
 030                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
 031                    new ArgumentOutOfRangeException(nameof(name), SR.SFxOperationDescriptionNameCannotBeEmpty));
 32            }
 33
 269234            XmlName = new XmlName(name, true /*isEncoded*/);
 269235            _declaringContract = declaringContract ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(n
 269236            IsInitiating = true;
 269237            IsTerminating = false;
 269238            Faults = new FaultDescriptionCollection();
 269239            Messages = new MessageDescriptionCollection();
 269240            Behaviors = new KeyedByTypeCollection<IOperationBehavior>();
 269241            KnownTypes = new Collection<Type>();
 269242            AuthorizeOperation = new KeyedByTypeCollection<IAuthorizeOperation>();
 269243        }
 44
 045        internal OperationDescription(string name, ContractDescription declaringContract, bool validateRpcWrapperName) :
 46        {
 047            IsValidateRpcWrapperName = validateRpcWrapperName;
 048        }
 49
 50        internal bool HasNoDisposableParameters
 51        {
 302652            get { return _hasNoDisposableParameters; }
 537253            set { _hasNoDisposableParameters = value; }
 54        }
 55
 56        // Not serializable on purpose, metadata import/export cannot
 57        // produce it, only available when binding to runtime
 4740958        public MethodInfo SyncMethod { get; set; }
 59
 60        // Not serializable on purpose, metadata import/export cannot
 61        // produce it, only available when binding to runtime
 883062        public MethodInfo BeginMethod { get; set; }
 63
 64        // Not serializable on purpose, metadata import/export cannot
 65        // produce it, only available when binding to runtime
 266        public MethodInfo EndMethod { get; set; }
 67
 68        // Not serializable on purpose, metadata import/export cannot
 69        // produce it, only available when binding to runtime
 2360070        public MethodInfo TaskMethod { get; set; }
 71
 72        internal MethodInfo OperationMethod
 73        {
 74            get
 75            {
 1209876                if (SyncMethod == null)
 77                {
 153478                    return TaskMethod ?? BeginMethod;
 79                }
 80                else
 81                {
 1056482                    return SyncMethod;
 83                }
 84            }
 85        }
 86
 25187        internal bool HasProtectionLevel => false;
 88
 89        public ContractDescription DeclaringContract
 90        {
 2644891            get { return _declaringContract; }
 92            set
 93            {
 094                if (value == null)
 95                {
 096                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(DeclaringContract));
 97                }
 98                else
 99                {
 0100                    _declaringContract = value;
 101                }
 0102            }
 103        }
 104
 4903105        public FaultDescriptionCollection Faults { get; }
 106
 107        public bool IsOneWay
 108        {
 9014109            get { return Messages.Count == 1; }
 110        }
 111
 1812112        public Collection<Type> KnownTypes { get; }
 113
 114        // Messages[0] is the 'request' (first of MEP), and for non-oneway MEPs, Messages[1] is the 'response' (second o
 113966115        public MessageDescriptionCollection Messages { get; }
 116
 117        internal string CodeName
 118        {
 5372119            get { return XmlName.DecodedName; }
 120        }
 121
 122        public string Name
 123        {
 23090124            get { return XmlName.EncodedName; }
 125        }
 126
 2752127        internal bool IsValidateRpcWrapperName { private set; get; } = true;
 128
 6148129        internal KeyedByTypeCollection<IAuthorizeOperation> AuthorizeOperation { get; }
 130
 2794131        internal GenericHashtable<Type, ReadOnlyCollection<IAuthorizeData>> AuthorizeData { get; set; }
 132
 133        public KeyedCollection<Type, IOperationBehavior> OperationBehaviors
 134        {
 26571135            get { return Behaviors; }
 136        }
 137
 67962138        internal KeyedByTypeCollection<IOperationBehavior> Behaviors { get; }
 139
 28624140        internal XmlName XmlName { get; }
 141
 14462142        public bool IsInitiating { get; set; }
 143
 144        internal bool IsServerInitiated()
 145        {
 9962146            EnsureInvariants();
 9962147            return Messages[0].Direction == MessageDirection.Output;
 148        }
 149
 11426150        public bool IsTerminating { get; set; }
 151
 152        internal void EnsureInvariants()
 153        {
 12990154            if (Messages.Count != 1 && Messages.Count != 2)
 155            {
 0156                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFx
 157            }
 12990158        }
 159
 160        internal Type TaskTResult
 161        {
 10162            get;
 329163            set;
 164        }
 165
 6429166        internal bool IsSessionOpenNotificationEnabled { get; set; }
 167    }
 168}