< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Dispatcher.JsonFormatMapping
Assembly: CoreWCF.WebHttp
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.WebHttp/src/CoreWCF/Dispatcher/JsonFormatMapping.cs
Line coverage
50%
Covered lines: 7
Uncovered lines: 7
Coverable lines: 14
Total lines: 46
Line coverage: 50%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

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

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.WebHttp/src/CoreWCF/Dispatcher/JsonFormatMapping.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.Collections.Generic;
 5using System.Text;
 6using System.Xml;
 7using CoreWCF.Channels;
 8using CoreWCF.Web;
 9
 10namespace CoreWCF.Dispatcher
 11{
 12    internal class JsonFormatMapping : MultiplexingFormatMapping
 13    {
 114        public static readonly WebContentFormat WebContentFormat = WebContentFormat.Json;
 15
 116        private static readonly string s_defaultMediaType = JsonGlobals.ApplicationJsonMediaType;
 117        private static readonly Dictionary<Encoding, MessageEncoder> s_encoders = new Dictionary<Encoding, MessageEncode
 118        private static readonly object s_thisLock = new object();
 19
 20        public JsonFormatMapping(Encoding writeEncoding, WebContentTypeMapper contentTypeMapper)
 3721            : base(writeEncoding, contentTypeMapper)
 3722        { }
 23
 024        public override WebContentFormat ContentFormat => WebContentFormat;
 25
 026        public override WebMessageFormat MessageFormat => WebMessageFormat.Json;
 27
 3728        public override string DefaultMediaType => s_defaultMediaType;
 29
 30        protected override MessageEncoder Encoder
 31        {
 32            get
 33            {
 034                lock (s_thisLock)
 35                {
 036                    if (!s_encoders.ContainsKey(writeEncoding))
 37                    {
 038                        s_encoders[writeEncoding] = new JsonMessageEncoderFactory(writeEncoding, 0, 0, new XmlDictionary
 39                    }
 040                }
 41
 042                return s_encoders[writeEncoding];
 43            }
 44        }
 45    }
 46}