< Summary

Class:Azure.Security.KeyVault.SerializationExtensions
Assembly:Azure.Security.KeyVault.Secrets
File(s):C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Shared\src\IJsonSerializable.cs
Covered lines:11
Uncovered lines:0
Coverable lines:11
Total lines:46
Line coverage:100% (11 of 11)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
Deserialize(...)-100%100%
Serialize(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Shared\src\IJsonSerializable.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using Azure.Core;
 5using System;
 6using System.IO;
 7using System.Text.Json;
 8
 9namespace Azure.Security.KeyVault
 10{
 11    internal interface IJsonSerializable
 12    {
 13        void WriteProperties(Utf8JsonWriter json);
 14    }
 15
 16    internal interface IJsonDeserializable
 17    {
 18        void ReadProperties(JsonElement json);
 19    }
 20
 21    internal static class SerializationExtensions
 22    {
 23        public static void Deserialize(this IJsonDeserializable obj, Stream content)
 24        {
 105225            using JsonDocument json = JsonDocument.Parse(content, default);
 105226            obj.ReadProperties(json.RootElement);
 210427        }
 28
 29        public static ReadOnlyMemory<byte> Serialize(this IJsonSerializable obj)
 30        {
 68831            var writer = new ArrayBufferWriter<byte>();
 32
 68833            using (var json = new Utf8JsonWriter(writer))
 34            {
 68835                json.WriteStartObject();
 36
 68837                obj.WriteProperties(json);
 38
 68839                json.WriteEndObject();
 68840                json.Flush();
 68841            }
 42
 68843            return writer.WrittenMemory;
 44        }
 45    }
 46}

Methods/Properties

Deserialize(...)
Serialize(...)