< Summary - Jellyfin

Information
Class: Jellyfin.Extensions.Json.Converters.JsonNullableGuidConverter
Assembly: Jellyfin.Extensions
File(s): /srv/git/jellyfin/src/Jellyfin.Extensions/Json/Converters/JsonNullableGuidConverter.cs
Line coverage
100%
Covered lines: 6
Uncovered lines: 0
Coverable lines: 6
Total lines: 31
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Read(...)100%11100%
Write(...)100%22100%

File(s)

/srv/git/jellyfin/src/Jellyfin.Extensions/Json/Converters/JsonNullableGuidConverter.cs

#LineLine coverage
 1using System;
 2using System.Text.Json;
 3using System.Text.Json.Serialization;
 4
 5namespace Jellyfin.Extensions.Json.Converters
 6{
 7    /// <summary>
 8    /// Converts a GUID object or value to/from JSON.
 9    /// </summary>
 10    public class JsonNullableGuidConverter : JsonConverter<Guid?>
 11    {
 12        /// <inheritdoc />
 13        public override Guid? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
 1114            => JsonGuidConverter.ReadInternal(ref reader);
 15
 16        /// <inheritdoc />
 17        public override void Write(Utf8JsonWriter writer, Guid? value, JsonSerializerOptions options)
 18        {
 19            // null got handled higher up the call stack
 3520            var val = value!.Value;
 3521            if (val.IsEmpty())
 22            {
 2623                writer.WriteNullValue();
 24            }
 25            else
 26            {
 927                JsonGuidConverter.WriteInternal(writer, val);
 28            }
 929        }
 30    }
 31}