< Summary

Class:Azure.Storage.StorageVersionExtensions
Assembly:Azure.Storage.Files.Shares
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Common\src\Shared\StorageVersionExtensions.cs
Covered lines:11
Uncovered lines:3
Coverable lines:14
Total lines:82
Line coverage:78.5% (11 of 14)
Covered branches:1
Total branches:4
Branch coverage:25% (1 of 4)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
ToVersionString(...)-78.57%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) =>
 336448            version switch
 336449            {
 336450#if BlobSDK || FileSDK || DataLakeSDK
 051                ServiceVersion.V2019_02_02 => "2019-02-02",
 052                ServiceVersion.V2019_07_07 => "2019-07-07",
 672853                ServiceVersion.V2019_12_12 => "2019-12-12",
 336454#elif QueueSDK
 336455                // Queues just bumped the version number without changing the swagger
 336456                ServiceVersion.V2019_02_02 => "2018-11-09",
 336457                ServiceVersion.V2019_07_07 => "2018-11-09",
 336458                ServiceVersion.V2019_12_12 => "2018-11-09",
 336459#endif
 060                _ => throw Errors.VersionNotSupported(nameof(version))
 336461            };
 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
 70            version switch
 71            {
 72                Azure.Storage.Files.DataLake.DataLakeClientOptions.ServiceVersion.V2019_02_02 =>
 73                             Azure.Storage.Blobs.BlobClientOptions.ServiceVersion.V2019_02_02,
 74                Azure.Storage.Files.DataLake.DataLakeClientOptions.ServiceVersion.V2019_07_07 =>
 75                             Azure.Storage.Blobs.BlobClientOptions.ServiceVersion.V2019_07_07,
 76                Azure.Storage.Files.DataLake.DataLakeClientOptions.ServiceVersion.V2019_12_12 =>
 77                             Azure.Storage.Blobs.BlobClientOptions.ServiceVersion.V2019_12_12,
 78                _ => throw Errors.VersionNotSupported(nameof(version))
 79            };
 80#endif
 81    }
 82}

Methods/Properties

ToVersionString(...)