< Summary

Information
Line coverage
0%
Covered lines: 0
Uncovered lines: 16
Coverable lines: 16
Total lines: 53
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

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

File(s)

C:\h\w\B31A098C\w\BB5A0A33\e\runtime-utils\Runner\runtime\src\libraries\System.Text.Json\src\System\Text\Json\Serialization\Attributes\JsonDerivedTypeAttribute.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
 4namespace System.Text.Json.Serialization
 5{
 6    /// <summary>
 7    /// When placed on a type declaration, indicates that the specified subtype should be opted into polymorphic seriali
 8    /// </summary>
 9    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true, Inherited = false)]
 10    public class JsonDerivedTypeAttribute : JsonAttribute
 11    {
 12        /// <summary>
 13        /// Initializes a new attribute with specified parameters.
 14        /// </summary>
 15        /// <param name="derivedType">A derived type that should be supported in polymorphic serialization of the declar
 016        public JsonDerivedTypeAttribute(Type derivedType)
 017        {
 018            DerivedType = derivedType;
 019        }
 20
 21        /// <summary>
 22        /// Initializes a new attribute with specified parameters.
 23        /// </summary>
 24        /// <param name="derivedType">A derived type that should be supported in polymorphic serialization of the declar
 25        /// <param name="typeDiscriminator">The type discriminator identifier to be used for the serialization of the su
 026        public JsonDerivedTypeAttribute(Type derivedType, string typeDiscriminator)
 027        {
 028            DerivedType = derivedType;
 029            TypeDiscriminator = typeDiscriminator;
 030        }
 31
 32        /// <summary>
 33        /// Initializes a new attribute with specified parameters.
 34        /// </summary>
 35        /// <param name="derivedType">A derived type that should be supported in polymorphic serialization of the declar
 36        /// <param name="typeDiscriminator">The type discriminator identifier to be used for the serialization of the su
 037        public JsonDerivedTypeAttribute(Type derivedType, int typeDiscriminator)
 038        {
 039            DerivedType = derivedType;
 040            TypeDiscriminator = typeDiscriminator;
 041        }
 42
 43        /// <summary>
 44        /// A derived type that should be supported in polymorphic serialization of the declared base type.
 45        /// </summary>
 046        public Type DerivedType { get; }
 47
 48        /// <summary>
 49        /// The type discriminator identifier to be used for the serialization of the subtype.
 50        /// </summary>
 051        public object? TypeDiscriminator { get; }
 52    }
 53}