< Summary

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

Metrics

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

File(s)

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

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Reflection;
 6using System.Runtime.Versioning;
 7
 8namespace Azure.Messaging.ServiceBus.Primitives
 9{
 10    internal static class ClientInfo
 11    {
 012        internal static Assembly assembly = GetAssesmbly();
 013        internal static readonly string Product = GetAssemblyAttributeValue<AssemblyProductAttribute>(assembly, p => p.P
 014        internal static readonly string Version = GetAssemblyAttributeValue<AssemblyFileVersionAttribute>(assembly, v =>
 015        internal static readonly string Framework = GetAssemblyAttributeValue<TargetFrameworkAttribute>(assembly, f => f
 16
 017        internal static readonly string Platform = GetPlatform();
 18
 19        internal static string GetPlatform()
 20        {
 21            try
 22            {
 23#if NETSTANDARD2_0
 024                return System.Runtime.InteropServices.RuntimeInformation.OSDescription;
 25#elif UAP10_0
 26                return "UAP";
 27#elif NET461
 28                return Environment.OSVersion.VersionString;
 29#else
 30                return "Unknown";
 31#endif
 32            }
 033            catch
 34            {
 35                // ignored
 036                return null;
 37            }
 038        }
 39
 40        internal static Assembly GetAssesmbly()
 41        {
 042            return typeof(ClientInfo).GetTypeInfo().Assembly;
 43        }
 44
 45        internal static string GetAssemblyAttributeValue<T>(Assembly assembly, Func<T, string> getter) where T : Attribu
 46        {
 047            return !(assembly.GetCustomAttribute(typeof(T)) is T attribute) ? null : getter(attribute);
 48        }
 49    }
 50}