< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Description.DataContractJsonSerializerOperationBehavior
Assembly: CoreWCF.WebHttp
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.WebHttp/src/CoreWCF/Description/DataContractJsonSerializerOperationBehavior.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 21
Coverable lines: 21
Total lines: 48
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%110%
CreateSerializer(...)0%220%
CreateSerializer(...)0%220%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.WebHttp/src/CoreWCF/Description/DataContractJsonSerializerOperationBehavior.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.Collections.Generic;
 6using System.Runtime.Serialization;
 7using System.Runtime.Serialization.Json;
 8using System.Xml;
 9
 10namespace CoreWCF.Description
 11{
 12    internal class DataContractJsonSerializerOperationBehavior : DataContractSerializerOperationBehavior
 13    {
 14        private readonly bool _alwaysEmitTypeInformation;
 15
 16        public DataContractJsonSerializerOperationBehavior(OperationDescription description, int maxItemsInObjectGraph, 
 017            : base(description)
 18        {
 019            MaxItemsInObjectGraph = maxItemsInObjectGraph;
 020            IgnoreExtensionDataObject = ignoreExtensionDataObject;
 021            _alwaysEmitTypeInformation = alwaysEmitTypeInformation;
 022        }
 23
 24        public override XmlObjectSerializer CreateSerializer(Type type, string name, string ns, IList<Type> knownTypes)
 25        {
 026            return new DataContractJsonSerializer(type, new DataContractJsonSerializerSettings
 027            {
 028                RootName = name,
 029                KnownTypes = knownTypes,
 030                MaxItemsInObjectGraph = MaxItemsInObjectGraph,
 031                IgnoreExtensionDataObject = IgnoreExtensionDataObject,
 032                EmitTypeInformation = _alwaysEmitTypeInformation ? EmitTypeInformation.Always : EmitTypeInformation.AsNe
 033            });
 34        }
 35
 36        public override XmlObjectSerializer CreateSerializer(Type type, XmlDictionaryString name, XmlDictionaryString ns
 37        {
 038            return new DataContractJsonSerializer(type, new DataContractJsonSerializerSettings
 039            {
 040                RootName = name.Value,
 041                KnownTypes = knownTypes,
 042                MaxItemsInObjectGraph = MaxItemsInObjectGraph,
 043                IgnoreExtensionDataObject = IgnoreExtensionDataObject,
 044                EmitTypeInformation = _alwaysEmitTypeInformation ? EmitTypeInformation.Always : EmitTypeInformation.AsNe
 045            });
 46        }
 47    }
 48}