< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.OperationBehaviorAttribute
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/OperationBehaviorAttribute.cs
Line coverage
59%
Covered lines: 16
Uncovered lines: 11
Coverable lines: 27
Total lines: 82
Line coverage: 59.2%
Branch coverage
41%
Covered branches: 5
Total branches: 12
Branch coverage: 41.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/OperationBehaviorAttribute.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 CoreWCF.Channels;
 6using CoreWCF.Description;
 7using CoreWCF.Dispatcher;
 8
 9namespace CoreWCF
 10{
 11    [AttributeUsage(CoreWCFAttributeTargets.OperationBehavior)]
 12    public sealed class OperationBehaviorAttribute : Attribute, IOperationBehavior
 13    {
 14        internal const ImpersonationOption DefaultImpersonationOption = ImpersonationOption.NotAllowed;
 15        private ImpersonationOption _impersonation = ImpersonationOption.NotAllowed;
 16        private ReleaseInstanceMode _releaseInstance = ReleaseInstanceMode.None;
 17
 608218        public bool AutoDisposeParameters { get; set; } = true;
 19
 20        public ImpersonationOption Impersonation
 21        {
 22            get
 23            {
 302624                return _impersonation;
 25            }
 26            set
 27            {
 49328                if (!ImpersonationOptionHelper.IsDefined(value))
 29                {
 030                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 31                }
 49332                _impersonation = value;
 49333            }
 34        }
 35
 36        public ReleaseInstanceMode ReleaseInstanceMode
 37        {
 038            get { return _releaseInstance; }
 39            set
 40            {
 041                if (!ReleaseInstanceModeHelper.IsDefined(value))
 42                {
 043                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 44                }
 45
 046                _releaseInstance = value;
 047            }
 48        }
 49
 318750        void IOperationBehavior.AddBindingParameters(OperationDescription operationDescription, BindingParameterCollecti
 264551        void IOperationBehavior.Validate(OperationDescription operationDescription) { }
 52
 53        void IOperationBehavior.ApplyDispatchBehavior(OperationDescription description, DispatchOperation dispatch)
 54        {
 302655            if (description == null)
 56            {
 057                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(description));
 58            }
 59
 302660            if (dispatch == null)
 61            {
 062                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(dispatch));
 63            }
 64
 302665            if (description.IsServerInitiated() && _releaseInstance != ReleaseInstanceMode.None)
 66            {
 067                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
 068                    SR.Format(SR.SFxOperationBehaviorAttributeReleaseInstanceModeDoesNotApplyToCallback,
 069                    description.Name)));
 70            }
 71
 302672            dispatch.AutoDisposeParameters = AutoDisposeParameters;
 302673            dispatch.ReleaseInstanceBeforeCall = (_releaseInstance & ReleaseInstanceMode.BeforeCall) != 0;
 302674            dispatch.ReleaseInstanceAfterCall = (_releaseInstance & ReleaseInstanceMode.AfterCall) != 0;
 302675            dispatch.Impersonation = Impersonation;
 302676        }
 77
 78        void IOperationBehavior.ApplyClientBehavior(OperationDescription description, ClientOperation proxy)
 79        {
 280        }
 81    }
 82}