< Summary

Information
Class: Elsa.Workflows.Api.Endpoints.Package.Version
Assembly: Elsa.Workflows.Api
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/Package/Endpoint.cs
Line coverage
33%
Covered lines: 3
Uncovered lines: 6
Coverable lines: 9
Total lines: 30
Line coverage: 33.3%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Configure()100%11100%
HandleAsync()100%210%
RemoveAutoGeneratedPostfix(...)0%620%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/Package/Endpoint.cs

#LineLine coverage
 1using System.Reflection;
 2using FastEndpoints;
 3using JetBrains.Annotations;
 4
 5namespace Elsa.Workflows.Api.Endpoints.Package;
 6
 7/// <summary>
 8/// Returns the package informational version.
 9/// </summary>
 10[PublicAPI]
 11internal class Version : EndpointWithoutRequest<Response>
 12{
 13    public override void Configure()
 14    {
 115        Get("/package/version");
 116        AllowAnonymous();
 117    }
 18
 19    public override async Task HandleAsync(CancellationToken cancellationToken)
 20    {
 021        var assembly = Assembly.GetExecutingAssembly();
 022        var versionAttribute = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
 023        var version = RemoveAutoGeneratedPostfix(versionAttribute);
 24
 025        await Send.OkAsync(new Response(version), cancellationToken);
 026    }
 27
 28    private static string RemoveAutoGeneratedPostfix(AssemblyInformationalVersionAttribute? versionAttribute) =>
 029        versionAttribute?.InformationalVersion.Split("+")[0]!;
 30}