< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Telemetry.AssemblyVersionExtensions
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Telemetry/AssemblyVersionExtensions.cs
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 31
Line coverage: 100%
Branch coverage
50%
Covered branches: 2
Total branches: 4
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
GetPackageVersion(...)50%44100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Telemetry/AssemblyVersionExtensions.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System;
 5using System.Diagnostics;
 6using System.Reflection;
 7
 8namespace CoreWCF.Telemetry;
 9
 10internal static class AssemblyVersionExtensions
 11{
 12    public static string GetPackageVersion(this Assembly assembly)
 13    {
 14        // MinVer https://github.com/adamralph/minver?tab=readme-ov-file#version-numbers
 15        // together with Microsoft.SourceLink.GitHub https://github.com/dotnet/sourcelink
 16        // fills AssemblyInformationalVersionAttribute by
 17        // {majorVersion}.{minorVersion}.{patchVersion}.{pre-release label}.{pre-release version}.{gitHeight}+{Git SHA o
 18        // Ex: 1.5.0-alpha.1.40+807f703e1b4d9874a92bd86d9f2d4ebe5b5d52e4
 19        // The following parts are optional: pre-release label, pre-release version, git height, Git SHA of current comm
 20        // For package version, value of AssemblyInformationalVersionAttribute without commit hash is returned.
 21
 822        var informationalVersion = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVe
 23        Debug.Assert(!string.IsNullOrEmpty(informationalVersion), "AssemblyInformationalVersionAttribute was not found i
 24
 825        var indexOfPlusSign = informationalVersion.IndexOf('+');
 26
 827        return indexOfPlusSign > 0
 828            ? informationalVersion.Substring(0, indexOfPlusSign)
 829            : informationalVersion;
 30    }
 31}