< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 15
Coverable lines: 15
Total lines: 39
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
Read(...)100%110%
Write(...)100%110%
ReadAsPropertyNameCore(...)100%110%
WriteAsPropertyNameCore(...)100%110%
GetSchema(...)100%110%
GetSupportedJsonValueTypes(...)100%110%

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/GuidConverter.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.Diagnostics;
 5using System.Text.Json.Nodes;
 6using System.Text.Json.Schema;
 7
 8namespace System.Text.Json.Serialization.Converters
 9{
 10    internal sealed class GuidConverter : JsonPrimitiveConverter<Guid>
 11    {
 12        public override Guid Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
 013        {
 014            return reader.GetGuid();
 015        }
 16
 17        public override void Write(Utf8JsonWriter writer, Guid value, JsonSerializerOptions options)
 018        {
 019            writer.WriteStringValue(value);
 020        }
 21
 22        internal override Guid ReadAsPropertyNameCore(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptio
 023        {
 024            Debug.Assert(reader.TokenType == JsonTokenType.PropertyName);
 025            return reader.GetGuidNoValidation();
 026        }
 27
 28        internal override void WriteAsPropertyNameCore(Utf8JsonWriter writer, Guid value, JsonSerializerOptions options,
 029        {
 030            writer.WritePropertyName(value);
 031        }
 32
 33        internal override JsonSchema? GetSchema(JsonNumberHandling numberHandling) =>
 034            new() { Type = JsonSchemaType.String, Format = "uuid" };
 35
 036        internal override JsonValueType GetSupportedJsonValueTypes(JsonNumberHandling _) => JsonValueType.String;
 37    }
 38}
 39