< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Dispatcher.DispatchOperation
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Dispatcher/DispatchOperation.cs
Line coverage
95%
Covered lines: 102
Uncovered lines: 5
Coverable lines: 107
Total lines: 239
Line coverage: 95.3%
Branch coverage
66%
Covered branches: 4
Total branches: 6
Branch coverage: 66.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)50%44100%
.ctor(...)100%11100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Dispatcher/DispatchOperation.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 CoreWCF.Collections.Generic;
 8using CoreWCF.IdentityModel.Claims;
 9using Microsoft.AspNetCore.Authorization;
 10
 11namespace CoreWCF.Dispatcher
 12{
 13    public sealed class DispatchOperation
 14    {
 15        private IDispatchFaultFormatter _faultFormatter;
 16        private ImpersonationOption _impersonation;
 17        private bool _isTerminating;
 18        private bool _isSessionOpenNotificationEnabled;
 19        private bool _releaseInstanceAfterCall;
 20        private bool _releaseInstanceBeforeCall;
 375021        private bool _deserializeRequest = true;
 375022        private bool _serializeReply = true;
 375023        private bool _autoDisposeParameters = true;
 24        private ConcurrentDictionary<string, List<Claim>> _authorizeClaims;
 25
 375026        public DispatchOperation(DispatchRuntime parent, string name, string action)
 27        {
 375028            Parent = parent ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(parent));
 375029            Name = name ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(name));
 375030            Action = action;
 375031            _impersonation = OperationBehaviorAttribute.DefaultImpersonationOption;
 32            // Not necessary for basic functionality
 375033            CallContextInitializers = parent.NewBehaviorCollection<ICallContextInitializer>();
 375034            FaultContractInfos = parent.NewBehaviorCollection<FaultContractInfo>();
 375035            ParameterInspectors = parent.NewBehaviorCollection<IParameterInspector>();
 375036            IsOneWay = true;
 375037            _authorizeClaims = new ConcurrentDictionary<string, List<Claim>>();
 375038        }
 39
 342640        public DispatchOperation(DispatchRuntime parent, string name, string action, string replyAction) : this(parent, 
 41        {
 342642            ReplyAction = replyAction;
 342643            IsOneWay = false;
 342644        }
 45
 651846        public string Action { get; }
 47
 735148        public SynchronizedCollection<ICallContextInitializer> CallContextInitializers { get; }
 49
 383750        public SynchronizedCollection<FaultContractInfo> FaultContractInfos { get; }
 51
 52        public IDispatchMessageFormatter Formatter
 53        {
 670054            get { return InternalFormatter; }
 55            set
 56            {
 304957                lock (Parent.ThisLock)
 58                {
 304959                    Parent.InvalidateRuntime();
 304960                    InternalFormatter = value;
 304961                }
 304962            }
 63        }
 64
 65        public IDispatchFaultFormatter FaultFormatter
 66        {
 67            get
 68            {
 383769                if (_faultFormatter == null)
 70                {
 366971                    _faultFormatter = new DataContractSerializerFaultFormatter(FaultContractInfos);
 72                }
 383773                return _faultFormatter;
 74            }
 75            set
 76            {
 16877                lock (Parent.ThisLock)
 78                {
 16879                    Parent.InvalidateRuntime();
 16880                    _faultFormatter = value;
 16881                    IsFaultFormatterSetExplicit = true;
 16882                }
 16883            }
 84        }
 85
 17386        internal bool IsFaultFormatterSetExplicit { get; private set; } = false;
 87
 88        public bool AutoDisposeParameters
 89        {
 367490            get { return _autoDisposeParameters; }
 91
 92            set
 93            {
 302694                lock (Parent.ThisLock)
 95                {
 302696                    Parent.InvalidateRuntime();
 302697                    _autoDisposeParameters = value;
 302698                }
 302699            }
 100        }
 101
 102        public bool DeserializeRequest
 103        {
 3674104            get { return _deserializeRequest; }
 105            set
 106            {
 3063107                lock (Parent.ThisLock)
 108                {
 3063109                    Parent.InvalidateRuntime();
 3063110                    _deserializeRequest = value;
 3063111                }
 3063112            }
 113        }
 114
 3674115        public bool IsOneWay { get; }
 116
 117        public ImpersonationOption Impersonation
 118        {
 3682119            get { return _impersonation; }
 120            set
 121            {
 3026122                lock (Parent.ThisLock)
 123                {
 3026124                    Parent.InvalidateRuntime();
 3026125                    _impersonation = value;
 3026126                }
 3026127            }
 128        }
 129
 130        public ConcurrentDictionary<string,List<Claim>> AuthorizeClaims
 131        {
 3868132            get { return _authorizeClaims; }
 133            set
 134            {
 0135                lock (Parent.ThisLock)
 136                {
 0137                    Parent.InvalidateRuntime();
 0138                    _authorizeClaims = value;
 0139                }
 0140            }
 141        }
 142
 6700143        internal bool HasNoDisposableParameters { get; set; }
 144
 10413145        internal IDispatchMessageFormatter InternalFormatter { get; set; }
 146
 11112147        internal IOperationInvoker InternalInvoker { get; set; }
 148
 149        public IOperationInvoker Invoker
 150        {
 7360151            get { return InternalInvoker; }
 152            set
 153            {
 3088154                lock (Parent.ThisLock)
 155                {
 3088156                    Parent.InvalidateRuntime();
 3088157                    InternalInvoker = value;
 3088158                }
 3088159            }
 160        }
 161
 162        internal bool IsTerminating
 163        {
 6687164            get { return _isTerminating; }
 165            set
 166            {
 3026167                lock (Parent.ThisLock)
 168                {
 3026169                    Parent.InvalidateRuntime();
 3026170                    _isTerminating = value;
 3026171                }
 3026172            }
 173        }
 174
 175        internal bool IsSessionOpenNotificationEnabled
 176        {
 3674177            get { return _isSessionOpenNotificationEnabled; }
 178            set
 179            {
 3026180                lock (Parent.ThisLock)
 181                {
 3026182                    Parent.InvalidateRuntime();
 3026183                    _isSessionOpenNotificationEnabled = value;
 3026184                }
 3026185            }
 186        }
 187
 46584188        public string Name { get; }
 189
 7348190        public ICollection<IParameterInspector> ParameterInspectors { get; }
 191
 68856192        public DispatchRuntime Parent { get; }
 193
 3953194        internal Lazy<AuthorizationPolicy> AuthorizationPolicy { get; set; }
 195
 3674196        internal ReceiveContextAcknowledgementMode ReceiveContextAcknowledgementMode { get; set; }
 197
 198        internal bool ReleaseInstanceAfterCall
 199        {
 3674200            get { return _releaseInstanceAfterCall; }
 201            set
 202            {
 3026203                lock (Parent.ThisLock)
 204                {
 3026205                    Parent.InvalidateRuntime();
 3026206                    _releaseInstanceAfterCall = value;
 3026207                }
 3026208            }
 209        }
 210
 211        internal bool ReleaseInstanceBeforeCall
 212        {
 3674213            get { return _releaseInstanceBeforeCall; }
 214            set
 215            {
 3026216                lock (Parent.ThisLock)
 217                {
 3026218                    Parent.InvalidateRuntime();
 3026219                    _releaseInstanceBeforeCall = value;
 3026220                }
 3026221            }
 222        }
 223
 3674224        public string ReplyAction { get; }
 225
 226        public bool SerializeReply
 227        {
 3674228            get { return _serializeReply; }
 229            set
 230            {
 3063231                lock (Parent.ThisLock)
 232                {
 3063233                    Parent.InvalidateRuntime();
 3063234                    _serializeReply = value;
 3063235                }
 3063236            }
 237        }
 238    }
 239}