< Summary

Information
Class: Spdx3.Model.Software.Classes.File
Assembly: Spdx3
File(s): /home/runner/work/Spdx3/Spdx3/Spdx3/Model/Software/Classes/File.cs
Line coverage
94%
Covered lines: 17
Uncovered lines: 1
Coverable lines: 18
Total lines: 68
Line coverage: 94.4%
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_ContentType()100%11100%
get_FileKind()100%11100%
get_Name()100%11100%
set_Name(...)100%22100%
.ctor()100%11100%
.ctor(...)100%22100%
Validate()50%2275%

File(s)

/home/runner/work/Spdx3/Spdx3/Spdx3/Model/Software/Classes/File.cs

#LineLine coverage
 1using System.Diagnostics.CodeAnalysis;
 2using System.Text.Json.Serialization;
 3using Spdx3.Exceptions;
 4using Spdx3.Model.Core.Classes;
 5using Spdx3.Model.Software.Enums;
 6using Spdx3.Serialization;
 7using Spdx3.Utility;
 8
 9namespace Spdx3.Model.Software.Classes;
 10
 11public class File : SoftwareArtifact
 12{
 13    private string _name;
 14
 15    [JsonPropertyName("software_contentType")]
 16    [JsonConverter(typeof(SpdxModelConverterFactory))]
 317    public string? ContentType { get; set; }
 18
 19    [JsonPropertyName("software_fileKind")]
 20    [JsonConverter(typeof(SpdxModelConverterFactory))]
 321    public FileKindType? FileKind { get; set; }
 22
 23    [JsonPropertyName("name")]
 24    [JsonConverter(typeof(SpdxModelConverterFactory))]
 25    public new string Name
 26    {
 827        get => _name;
 28        set
 29        {
 330            if (string.IsNullOrWhiteSpace(value))
 31            {
 132                throw new Spdx3ValidationException(this, nameof(Name), "Cannot be null, empty, or whitespace.");
 33            }
 34
 235            _name = value;
 236        }
 37    }
 38
 39    // protected internal no-parm constructor required for deserialization
 40#pragma warning disable CS8618, CS9264
 41    // ReSharper disable once UnusedMember.Global
 442    protected internal File()
 43    {
 444    }
 45#pragma warning restore CS8618, CS9264
 46
 47    [SetsRequiredMembers]
 648    public File(Catalog catalog, CreationInfo creationInfo, string name) : base(catalog, creationInfo)
 49    {
 650        if (string.IsNullOrWhiteSpace(name))
 51        {
 152            throw new Spdx3ValidationException(this, nameof(Name), "Cannot be null, empty, or whitespace.");
 53        }
 54
 555        _name = name;
 556    }
 57
 58
 59    public override void Validate()
 60    {
 461        base.Validate();
 62
 263        if (string.IsNullOrWhiteSpace(Name))
 64        {
 065            throw new Spdx3ValidationException(this, nameof(Name), "Cannot be null, empty, or whitespace.");
 66        }
 267    }
 68}