< Summary

Class:Azure.Storage.StorageVersionExtensions
Assembly:Azure.Storage.Files.DataLake
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Common\src\Shared\StorageVersionExtensions.cs
Covered lines:18
Uncovered lines:6
Coverable lines:24
Total lines:82
Line coverage:75% (18 of 24)
Covered branches:2
Total branches:8
Branch coverage:25% (2 of 8)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
ToVersionString(...)-78.57%25%
AsBlobsVersion(...)-70%25%

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Common\src\Shared\StorageVersionExtensions.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5
 6// Alias the ServiceVersion enum used by the service importing this shared
 7// source file
 8using ServiceVersion =
 9#if BlobSDK
 10    Azure.Storage.Blobs.BlobClientOptions.ServiceVersion;
 11#elif QueueSDK
 12    Azure.Storage.Queues.QueueClientOptions.ServiceVersion;
 13#elif FileSDK
 14    Azure.Storage.Files.Shares.ShareClientOptions.ServiceVersion;
 15#elif DataLakeSDK
 16    Azure.Storage.Files.DataLake.DataLakeClientOptions.ServiceVersion;
 17#else
 18    // If you see this error, you've included this shared source file from a
 19    // client library that it doesn't know how to help you with.  Either add
 20    // the appropriate XyzSDK flag to your .csproj or alias your service
 21    // version above.
 22    ERROR_STORAGE_SERVICE_NOT_DEFINED;
 23#endif
 24
 25namespace Azure.Storage
 26{
 27    /// <summary>
 28    /// Helpers to manage Storage service versions.
 29    /// </summary>
 30    internal static class StorageVersionExtensions
 31    {
 32        /// <summary>
 33        /// Gets the latest version of the service supported by this SDK.
 34        /// </summary>
 35        public const ServiceVersion LatestVersion =
 36#if BlobSDK || QueueSDK || FileSDK || DataLakeSDK
 37            ServiceVersion.V2019_12_12;
 38#else
 39            ERROR_STORAGE_SERVICE_NOT_DEFINED;
 40#endif
 41
 42        /// <summary>
 43        /// Convert a Storage ServiceVersion enum to an x-ms-version string.
 44        /// </summary>
 45        /// <param name="version">The service version enum value.</param>
 46        /// <returns>The x-ms-version string.</returns>
 47        public static string ToVersionString(this ServiceVersion version) =>
 462848            version switch
 462849            {
 462850#if BlobSDK || FileSDK || DataLakeSDK
 051                ServiceVersion.V2019_02_02 => "2019-02-02",
 052                ServiceVersion.V2019_07_07 => "2019-07-07",
 925653                ServiceVersion.V2019_12_12 => "2019-12-12",
 462854#elif QueueSDK
 462855                // Queues just bumped the version number without changing the swagger
 462856                ServiceVersion.V2019_02_02 => "2018-11-09",
 462857                ServiceVersion.V2019_07_07 => "2018-11-09",
 462858                ServiceVersion.V2019_12_12 => "2018-11-09",
 462859#endif
 060                _ => throw Errors.VersionNotSupported(nameof(version))
 462861            };
 62
 63#if DataLakeSDK
 64        /// <summary>
 65        /// Convert a DataLake ServiceVersion to a Blobs ServiceVersion.
 66        /// </summary>
 67        /// <param name="version">The DataLake service version.</param>
 68        /// <returns>The Blobs service version.</returns>
 69        public static Azure.Storage.Blobs.BlobClientOptions.ServiceVersion AsBlobsVersion(this Azure.Storage.Files.DataL
 1036270            version switch
 1036271            {
 1036272                Azure.Storage.Files.DataLake.DataLakeClientOptions.ServiceVersion.V2019_02_02 =>
 073                             Azure.Storage.Blobs.BlobClientOptions.ServiceVersion.V2019_02_02,
 1036274                Azure.Storage.Files.DataLake.DataLakeClientOptions.ServiceVersion.V2019_07_07 =>
 075                             Azure.Storage.Blobs.BlobClientOptions.ServiceVersion.V2019_07_07,
 1036276                Azure.Storage.Files.DataLake.DataLakeClientOptions.ServiceVersion.V2019_12_12 =>
 2072477                             Azure.Storage.Blobs.BlobClientOptions.ServiceVersion.V2019_12_12,
 078                _ => throw Errors.VersionNotSupported(nameof(version))
 1036279            };
 80#endif
 81    }
 82}