< Summary

Class:Microsoft.Azure.ServiceBus.Primitives.ClientInfo
Assembly:Microsoft.Azure.ServiceBus
File(s):C:\Git\azure-sdk-for-net\sdk\servicebus\Microsoft.Azure.ServiceBus\src\Primitives\ClientInfo.cs
Covered lines:0
Uncovered lines:10
Coverable lines:10
Total lines:46
Line coverage:0% (0 of 10)
Covered branches:0
Total branches:2
Branch coverage:0% (0 of 2)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.cctor()-0%100%
GetAssemblyAttributeValue(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\servicebus\Microsoft.Azure.ServiceBus\src\Primitives\ClientInfo.cs

#LineLine coverage
 1// Copyright (c) Microsoft. All rights reserved.
 2// Licensed under the MIT license. See LICENSE file in the project root for full license information.
 3
 4namespace Microsoft.Azure.ServiceBus.Primitives
 5{
 6    using System;
 7    using System.Reflection;
 8    using System.Runtime.Versioning;
 9
 10    internal static class ClientInfo
 11    {
 12        internal static readonly string Product;
 13        internal static readonly string Version;
 14        internal static readonly string Framework;
 15        internal static readonly string Platform;
 16
 17        static ClientInfo()
 18        {
 19            try
 20            {
 021                var assembly = typeof(ClientInfo).GetTypeInfo().Assembly;
 022                Product = GetAssemblyAttributeValue<AssemblyProductAttribute>(assembly, p => p.Product);
 023                Version = GetAssemblyAttributeValue<AssemblyFileVersionAttribute>(assembly, v => v.Version);
 024                Framework = GetAssemblyAttributeValue<TargetFrameworkAttribute>(assembly, f => f.FrameworkName);
 25#if NETSTANDARD2_0
 026                Platform = System.Runtime.InteropServices.RuntimeInformation.OSDescription;
 27#elif UAP10_0
 28                Platform = "UAP";
 29#elif NET461
 30                Platform = Environment.OSVersion.VersionString;
 31#else
 32                Platform = "Unknown";
 33#endif
 034            }
 035            catch
 36            {
 37                // ignored
 038            }
 039        }
 40
 41        static string GetAssemblyAttributeValue<T>(Assembly assembly, Func<T, string> getter) where T : Attribute
 42        {
 043            return !(assembly.GetCustomAttribute(typeof(T)) is T attribute) ? null : getter(attribute);
 44        }
 45    }
 46}