< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.XmlSerializerFormatAttribute
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/XmlSerializerFormatAttribute.cs
Line coverage
75%
Covered lines: 15
Uncovered lines: 5
Coverable lines: 20
Total lines: 64
Line coverage: 75%
Branch coverage
40%
Covered branches: 4
Total branches: 10
Branch coverage: 40%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
ValidateOperationFormatStyle(...)50%2266.66%
ValidateOperationFormatUse(...)50%2266.66%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/XmlSerializerFormatAttribute.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;
 5
 6namespace CoreWCF
 7{
 8    [AttributeUsage(CoreWCFAttributeTargets.ServiceContract | CoreWCFAttributeTargets.OperationContract, Inherited = fal
 9    public sealed class XmlSerializerFormatAttribute : Attribute
 10    {
 11        private OperationFormatStyle _style;
 12        private bool _isStyleSet;
 13        private OperationFormatUse _use;
 14
 27415        public bool SupportFaults { get; set; } = false;
 16
 17        public OperationFormatStyle Style
 18        {
 21819            get { return _style; }
 20            set
 21            {
 18322                ValidateOperationFormatStyle(value);
 18323                _style = value;
 18324                _isStyleSet = true;
 18325            }
 26        }
 27
 28        public OperationFormatUse Use
 29        {
 030            get { return _use; }
 31            set
 32            {
 16933                ValidateOperationFormatUse(value);
 16934                _use = value;
 16935                if (!_isStyleSet && IsEncoded)
 36                {
 037                    Style = OperationFormatStyle.Rpc;
 38                }
 16939            }
 40        }
 41
 42        internal bool IsEncoded
 43        {
 30644            get { return _use == OperationFormatUse.Encoded; }
 045            set { _use = value ? OperationFormatUse.Encoded : OperationFormatUse.Literal; }
 46        }
 47
 48        internal static void ValidateOperationFormatStyle(OperationFormatStyle value)
 49        {
 18350            if (!OperationFormatStyleHelper.IsDefined(value))
 51            {
 052                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(value))
 53            }
 18354        }
 55
 56        internal static void ValidateOperationFormatUse(OperationFormatUse value)
 57        {
 16958            if (!OperationFormatUseHelper.IsDefined(value))
 59            {
 060                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(value))
 61            }
 16962        }
 63    }
 64}