< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Dispatcher.MessageOperationFormatter
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Dispatcher/MessageOperationFormatter.cs
Line coverage
39%
Covered lines: 11
Uncovered lines: 17
Coverable lines: 28
Total lines: 102
Line coverage: 39.2%
Branch coverage
34%
Covered branches: 9
Total branches: 26
Branch coverage: 34.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
DeserializeReply(...)0%660%
DeserializeRequest(...)50%6662.5%
IsFault(...)100%110%
SerializeFault(...)100%110%
SerializeReply(...)66.66%6660%
SerializeRequest(...)0%660%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Dispatcher/MessageOperationFormatter.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.Diagnostics;
 7
 8namespace CoreWCF.Dispatcher
 9{
 10    internal sealed class MessageOperationFormatter : IClientMessageFormatter, IDispatchMessageFormatter
 11    {
 12        private static MessageOperationFormatter s_instance;
 13
 14        internal static MessageOperationFormatter Instance
 15        {
 16            get
 17            {
 66418                if (s_instance == null)
 19                {
 1420                    s_instance = new MessageOperationFormatter();
 21                }
 22
 66423                return s_instance;
 24            }
 25        }
 26
 27        public object DeserializeReply(Message message, object[] parameters)
 28        {
 029            if (message == null)
 30            {
 031                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(message));
 32            }
 33
 034            if (parameters != null && parameters.Length > 0)
 35            {
 036                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.SFxParametersMustBeEmpty);
 37            }
 38
 039            return message;
 40        }
 41
 42        public void DeserializeRequest(Message message, object[] parameters)
 43        {
 1044            if (message == null)
 45            {
 046                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(message));
 47            }
 48
 1049            if (parameters == null)
 50            {
 051                throw TraceUtility.ThrowHelperError(new ArgumentNullException(nameof(parameters)), message);
 52            }
 53
 1054            if (parameters.Length != 1)
 55            {
 056                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.SFxParameterMustBeArrayOfOneElement);
 57            }
 58
 1059            parameters[0] = message;
 1060        }
 61
 62        public bool IsFault(string operation, Exception error)
 63        {
 064            return false;
 65        }
 66
 67        public MessageFault SerializeFault(Exception error)
 68        {
 069            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.SFxMessageOperati
 70        }
 71
 72        public Message SerializeReply(MessageVersion messageVersion, object[] parameters, object result)
 73        {
 1074            if (!(result is Message))
 75            {
 076                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.SFxResultMustBeMessage);
 77            }
 78
 1079            if (parameters != null && parameters.Length > 0)
 80            {
 081                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.SFxParametersMustBeEmpty);
 82            }
 83
 1084            return (Message)result;
 85        }
 86
 87        public Message SerializeRequest(MessageVersion messageVersion, object[] parameters)
 88        {
 089            if (parameters == null)
 90            {
 091                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(parameters));
 92            }
 93
 094            if (parameters.Length != 1 || !(parameters[0] is Message))
 95            {
 096                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.SFxParameterMustBeMessage);
 97            }
 98
 099            return (Message)parameters[0];
 100        }
 101    }
 102}