< Summary

Information
Class: DotNetApiDiff.Models.ApiMember
Assembly: DotNetApiDiff
File(s): /home/runner/work/dotnet-api-diff/dotnet-api-diff/src/DotNetApiDiff/Models/ApiMember.cs
Line coverage
100%
Covered lines: 25
Uncovered lines: 0
Coverable lines: 25
Total lines: 93
Line coverage: 100%
Branch coverage
100%
Covered branches: 8
Total branches: 8
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Name()100%11100%
get_FullName()100%11100%
get_Type()100%11100%
get_Accessibility()100%11100%
get_Signature()100%11100%
get_Attributes()100%11100%
get_DeclaringType()100%11100%
get_Namespace()100%11100%
IsValid()100%44100%
ToString()100%11100%
Equals(...)100%44100%
GetHashCode()100%11100%

File(s)

/home/runner/work/dotnet-api-diff/dotnet-api-diff/src/DotNetApiDiff/Models/ApiMember.cs

#LineLine coverage
 1// Copyright DotNet API Diff Project Contributors - SPDX Identifier: MIT
 2using System.ComponentModel.DataAnnotations;
 3
 4namespace DotNetApiDiff.Models;
 5
 6/// <summary>
 7/// Represents a public API member from a .NET assembly
 8/// </summary>
 9public class ApiMember
 10{
 11    /// <summary>
 12    /// Simple name of the member
 13    /// </summary>
 14    [Required]
 22215    public string Name { get; set; } = string.Empty;
 16
 17    /// <summary>
 18    /// Full qualified name of the member
 19    /// </summary>
 20    [Required]
 25321    public string FullName { get; set; } = string.Empty;
 22
 23    /// <summary>
 24    /// Type of the member (Class, Method, Property, etc.)
 25    /// </summary>
 7626    public MemberType Type { get; set; }
 27
 28    /// <summary>
 29    /// Accessibility level of the member
 30    /// </summary>
 6831    public AccessibilityLevel Accessibility { get; set; }
 32
 33    /// <summary>
 34    /// Normalized signature of the member for comparison
 35    /// </summary>
 36    [Required]
 21637    public string Signature { get; set; } = string.Empty;
 38
 39    /// <summary>
 40    /// List of attributes applied to the member
 41    /// </summary>
 13742    public List<string> Attributes { get; set; } = new List<string>();
 43
 44    /// <summary>
 45    /// Name of the type that declares this member
 46    /// </summary>
 12047    public string DeclaringType { get; set; } = string.Empty;
 48
 49    /// <summary>
 50    /// Namespace containing this member
 51    /// </summary>
 12452    public string Namespace { get; set; } = string.Empty;
 53
 54    /// <summary>
 55    /// Validates the ApiMember instance
 56    /// </summary>
 57    /// <returns>True if valid, false otherwise</returns>
 58    public bool IsValid()
 759    {
 760        return !string.IsNullOrWhiteSpace(Name) &&
 761               !string.IsNullOrWhiteSpace(FullName) &&
 762               !string.IsNullOrWhiteSpace(Signature);
 763    }
 64
 65    /// <summary>
 66    /// Gets a string representation of the member
 67    /// </summary>
 68    public override string ToString()
 169    {
 170        return $"{Type} {FullName} ({Accessibility})";
 171    }
 72
 73    /// <summary>
 74    /// Determines equality based on FullName and Signature
 75    /// </summary>
 76    public override bool Equals(object? obj)
 577    {
 578        if (obj is not ApiMember other)
 279        {
 280            return false;
 81        }
 82
 383        return FullName == other.FullName && Signature == other.Signature;
 584    }
 85
 86    /// <summary>
 87    /// Gets hash code based on FullName and Signature
 88    /// </summary>
 89    public override int GetHashCode()
 290    {
 291        return HashCode.Combine(FullName, Signature);
 292    }
 93}