< Summary - SonghayCore

Information
Class: Songhay.Models.ProgramAssemblyInfo
Assembly: SonghayCore
File(s): /home/rasx/sourceRoot/SonghayCore/SonghayCore/Models/ProgramAssemblyInfo.cs
Line coverage
62%
Covered lines: 27
Uncovered lines: 16
Coverable lines: 43
Total lines: 133
Line coverage: 62.7%
Branch coverage
30%
Covered branches: 8
Total branches: 26
Branch coverage: 30.7%
Method coverage

Method coverage is only available for sponsors.

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.ctor(...)100%1100%
get_AssemblyTitle()50%6100%
get_AssemblyVersion()50%4100%
get_AssemblyVersionDetail()0%40%
get_AssemblyDescription()33.33%6100%
get_AssemblyProduct()0%20%
get_AssemblyCopyright()50%2100%
get_AssemblyCompany()0%20%
ToString()100%10%

File(s)

/home/rasx/sourceRoot/SonghayCore/SonghayCore/Models/ProgramAssemblyInfo.cs

#LineLine coverage
 1namespace Songhay.Models;
 2
 3/// <summary>
 4/// Defines Assembly information.
 5/// </summary>
 6/// <remarks>
 7/// This definition was developed
 8/// for About… dialogs in Windows Forms.
 9/// </remarks>
 10public class ProgramAssemblyInfo : IProgramAssemblyInfo
 11{
 12    /// <summary>
 13    /// Constructor of this class.
 14    /// </summary>
 15    /// <param name="targetAssembly">The target <see cref="System.Reflection.Assembly"/></param>
 116    public ProgramAssemblyInfo(Assembly? targetAssembly)
 117    {
 118        ArgumentNullException.ThrowIfNull(targetAssembly);
 19
 120        _dll = targetAssembly;
 121    }
 22
 23    /// <summary>
 24    /// Gets title of assembly.
 25    /// </summary>
 26    public string AssemblyTitle
 27    {
 28        get
 129        {
 130            object[] attributes = _dll.GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
 31
 132            if (attributes.Length <= 0) return Path.GetFileNameWithoutExtension(_dll.Location);
 33
 134            var titleAttribute = attributes[0] as AssemblyTitleAttribute;
 35
 136            return string.IsNullOrWhiteSpace(titleAttribute?.Title)
 137                ? Path.GetFileNameWithoutExtension(_dll.Location)
 138                : titleAttribute.Title;
 139        }
 40    }
 41
 42    /// <summary>
 43    /// Gets Assembly version information.
 44    /// </summary>
 45    public string AssemblyVersion
 46    {
 47        get
 148        {
 149            AssemblyName name = _dll.GetName();
 50
 151            return name.Version?.ToString() ?? string.Empty;
 152        }
 53    }
 54
 55    /// <summary>
 56    /// Gets detailed Assembly version information.
 57    /// </summary>
 58    public string AssemblyVersionDetail
 59    {
 60        get
 061        {
 062            AssemblyName dllName = _dll.GetName();
 63
 064            return $"{dllName.Version?.Major ?? 0:D}.{dllName.Version?.Minor ?? 0:D2}";
 065        }
 66    }
 67
 68    /// <summary>
 69    /// Gets Assembly description information.
 70    /// </summary>
 71    public string AssemblyDescription
 72    {
 73        get
 174        {
 175            object[] attributes = _dll.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
 76
 177            return attributes.Length == 0
 178                ? string.Empty
 179                : (attributes[0] as AssemblyDescriptionAttribute)?.Description ?? string.Empty;
 180        }
 81    }
 82
 83    /// <summary>
 84    /// Gets Assembly product information.
 85    /// </summary>
 86    public string AssemblyProduct
 87    {
 88        get
 089        {
 090            object[] attributes = _dll.GetCustomAttributes(typeof(AssemblyProductAttribute), false);
 91
 092            return attributes.Length == 0 ? string.Empty : ((AssemblyProductAttribute) attributes[0]).Product;
 093        }
 94    }
 95
 96    /// <summary>
 97    /// Gets Assembly copyright information.
 98    /// </summary>
 99    public string AssemblyCopyright
 100    {
 101        get
 1102        {
 1103            object[] attributes = _dll.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
 104
 1105            return attributes.Length == 0 ? string.Empty : ((AssemblyCopyrightAttribute) attributes[0]).Copyright;
 1106        }
 107    }
 108
 109    /// <summary>
 110    /// Gets Assembly company information.
 111    /// </summary>
 112    public string AssemblyCompany
 113    {
 114        get
 0115        {
 0116            object[] attributes = _dll.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
 117
 0118            return attributes.Length == 0 ? string.Empty : ((AssemblyCompanyAttribute) attributes[0]).Company;
 0119        }
 120    }
 121
 122    /// <summary>
 123    /// Returns format: <c>[AssemblyCompany], [AssemblyTitle] Version: [AssemblyVersion], [AssemblyVersionDetail]</c>.
 124    /// </summary>
 125    public override string ToString()
 0126    {
 0127        string s = $"{AssemblyCompany}, {AssemblyTitle} Version: {AssemblyVersion}, {AssemblyVersionDetail}";
 128
 0129        return s;
 0130    }
 131
 132    readonly Assembly _dll;
 133}