< Summary

Class:Azure.Core.XmlWriterExtensions
Assembly:Azure.Analytics.Synapse.Spark
File(s):C:\Git\azure-sdk-for-net\sdk\core\Azure.Core\src\Shared\AutoRest\XmlWriterExtensions.cs
Covered lines:0
Uncovered lines:8
Coverable lines:8
Total lines:43
Line coverage:0% (0 of 8)
Covered branches:0
Total branches:4
Branch coverage:0% (0 of 4)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
WriteObjectValue(...)-0%0%
WriteValue(...)-0%100%
WriteValue(...)-0%100%
WriteValue(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\core\Azure.Core\src\Shared\AutoRest\XmlWriterExtensions.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4#nullable enable
 5
 6using System;
 7using System.Xml;
 8
 9namespace Azure.Core
 10{
 11    internal static class XmlWriterExtensions
 12    {
 13        public static void WriteObjectValue(this XmlWriter writer, object value, string? nameHint)
 14        {
 15            switch (value)
 16            {
 17                case IXmlSerializable serializable:
 018                    serializable.Write(writer, nameHint);
 019                    return;
 20                default:
 021                    throw new NotImplementedException();
 22            }
 23        }
 24
 25        public static void WriteValue(this XmlWriter writer, DateTimeOffset value, string format) =>
 026            writer.WriteValue(TypeFormatters.ToString(value, format));
 27
 28        public static void WriteValue(this XmlWriter writer, TimeSpan value, string format) =>
 029            writer.WriteValue(TypeFormatters.ToString(value, format));
 30
 31        public static void WriteValue(this XmlWriter writer, byte[] value, string format)
 32        {
 33            switch (format)
 34            {
 35                case "U":
 036                    writer.WriteValue(TypeFormatters.ToBase64UrlString(value));
 037                    break;
 38                default:
 039                    throw new ArgumentException($"Format is not supported: '{format}'", nameof(format));
 40            }
 41        }
 42    }
 43}