< Summary

Information
Class: Dotnet.Installer.Core.Services.Implementations.LimitsService
Assembly: Dotnet.Installer.Core
File(s): /home/runner/work/dotnet-snap/dotnet-snap/src/Dotnet.Installer.Core/Services/Implementations/LimitsService.cs
Line coverage
100%
Covered lines: 16
Uncovered lines: 0
Coverable lines: 16
Total lines: 35
Line coverage: 100%
Branch coverage
83%
Covered branches: 5
Total branches: 6
Branch coverage: 83.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Runtime()100%11100%
get_Sdk()100%11100%
.ctor(...)83.33%66100%

File(s)

/home/runner/work/dotnet-snap/dotnet-snap/src/Dotnet.Installer.Core/Services/Implementations/LimitsService.cs

#LineLine coverage
 1using System.Text.Json;
 2using Dotnet.Installer.Core.Services.Contracts;
 3using Dotnet.Installer.Core.Types;
 4
 5namespace Dotnet.Installer.Core.Services.Implementations;
 6
 7public class LimitsService : ILimitsService
 8{
 29    public DotnetVersion Runtime { get; }
 410    public IEnumerable<DotnetVersion> Sdk { get; }
 11
 512    public LimitsService(IFileService fileService)
 513    {
 14        // Read limits file
 515        var limitsFilePath = Environment.GetEnvironmentVariable("LIMITS_PATH") ?? string.Empty;
 16
 517        if (!fileService.FileExists(limitsFilePath)) throw new ApplicationException("Limits file could not be found.");
 18
 519        using var fs = fileService.OpenRead(limitsFilePath);
 520        var limits = JsonDocument.Parse(fs);
 21
 422        Runtime = limits.RootElement.GetProperty("runtime").Deserialize<DotnetVersion>()!;
 323        Sdk = limits.RootElement.GetProperty("sdk").Deserialize<IEnumerable<DotnetVersion>>()!;
 24
 25        // Max out the revision to avoid installations failing when a new revision
 26        // comes out and the comparison between e.g. 8.0.101+1 <= 8.0.101 fails
 27        // when assessing whether that specific version can be installed with
 28        // the current host.
 129        Runtime.Revision = int.MaxValue;
 730        foreach (var sdkVersion in Sdk)
 231        {
 232            sdkVersion.Revision = int.MaxValue;
 233        }
 234    }
 35}