< Summary

Information
Class: System.Text.Json.Serialization.Converters.UnsupportedTypeConverter<T>
Assembly: System.Text.Json
File(s): C:\h\w\B31A098C\w\BB5A0A33\e\runtime-utils\Runner\runtime\src\libraries\System.Text.Json\src\System\Text\Json\Serialization\Converters\Value\UnsupportedTypeConverter.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 5
Coverable lines: 5
Total lines: 26
Line coverage: 0%
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
.ctor(...)100%110%
Read(...)100%110%
Write(...)100%110%
GetSchema(...)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\Converters\Value\UnsupportedTypeConverter.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.Text.Json.Schema;
 5using System.Text.Json.Nodes;
 6
 7namespace System.Text.Json.Serialization.Converters
 8{
 9    internal sealed class UnsupportedTypeConverter<T> : JsonConverter<T>
 10    {
 11        private readonly string? _errorMessage;
 12
 013        public UnsupportedTypeConverter(string? errorMessage = null) => _errorMessage = errorMessage;
 14
 015        public string ErrorMessage => _errorMessage ?? SR.Format(SR.SerializeTypeInstanceNotSupported, typeof(T).FullNam
 16
 17        public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) =>
 018            throw new NotSupportedException(ErrorMessage);
 19
 20        public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options) =>
 021            throw new NotSupportedException(ErrorMessage);
 22
 23        internal override JsonSchema? GetSchema(JsonNumberHandling _) =>
 024            new JsonSchema { Comment = "Unsupported .NET type", Not = JsonSchema.CreateTrueSchema() };
 25    }
 26}