< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.ExceptionDetail
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/ExceptionDetail.cs
Line coverage
52%
Covered lines: 13
Uncovered lines: 12
Coverable lines: 25
Total lines: 72
Line coverage: 52%
Branch coverage
25%
Covered branches: 2
Total branches: 8
Branch coverage: 25%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)50%4480%
ToString()100%110%
ToStringHelper(...)0%440%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/ExceptionDetail.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.Globalization;
 6using System.Runtime.Serialization;
 7using System.Text;
 8
 9namespace CoreWCF
 10{
 11    [DataContract(Namespace = "http://schemas.datacontract.org/2004/07/System.ServiceModel")]
 12    public class ExceptionDetail
 13    {
 414        public ExceptionDetail(Exception exception)
 15        {
 416            if (exception == null)
 17            {
 018                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(exception));
 19            }
 20
 421            HelpLink = exception.HelpLink;
 422            Message = exception.Message;
 423            StackTrace = exception.StackTrace;
 424            Type = exception.GetType().ToString();
 25
 426            if (exception.InnerException != null)
 27            {
 028                InnerException = new ExceptionDetail(exception.InnerException);
 29            }
 430        }
 31
 32        [DataMember]
 833        public string HelpLink { get; set; }
 34
 35        [DataMember]
 436        public ExceptionDetail InnerException { get; set; }
 37
 38        [DataMember]
 839        public string Message { get; set; }
 40
 41        [DataMember]
 842        public string StackTrace { get; set; }
 43
 44        [DataMember]
 845        public string Type { get; set; }
 46
 47        public override string ToString()
 48        {
 049            return string.Format(CultureInfo.InvariantCulture, "{0}\n{1}", SR.SFxExceptionDetailFormat, ToStringHelper(f
 50        }
 51
 52        internal string ToStringHelper(bool isInner)
 53        {
 054            StringBuilder sb = new StringBuilder();
 055            sb.AppendFormat("{0}: {1}", Type, Message);
 056            if (InnerException != null)
 57            {
 058                sb.AppendFormat(" ----> {0}", InnerException.ToStringHelper(true));
 59            }
 60            else
 61            {
 062                sb.Append("\n");
 63            }
 064            sb.Append(StackTrace);
 065            if (isInner)
 66            {
 067                sb.AppendFormat("\n   {0}\n", SR.SFxExceptionDetailEndOfInner);
 68            }
 069            return sb.ToString();
 70        }
 71    }
 72}