src/SSC/Internal/TypeMetadataResolver.cs
実行済みCoberturaのhit数が1以上の行です。
未実行カバレッジ対象ですがhit数が0の行です。
対象外Coberturaに実行対象として記録されていない行です。
| 行 | 行状態 | Hits | Source |
|---|---|---|---|
| 1 | 対象外 | — | using System.Collections.Concurrent; |
| 2 | 対象外 | — | using System.Reflection; |
| 3 | 対象外 | — | |
| 4 | 対象外 | — | namespace SSC.Internal; |
| 5 | 対象外 | — | |
| 6 | 対象外 | — | internal static class TypeMetadataResolver |
| 7 | 対象外 | — | { |
| 8 | 実行済み | 2 | private static readonly ConcurrentDictionary<Type, ComparableMember[]> MemberCache = new(); |
| 9 | 実行済み | 2 | private static readonly ConcurrentDictionary<Type, ComparableMember?> CompareKeyCache = new(); |
| 10 | 対象外 | — | |
| 11 | 対象外 | — | public static ComparableMember[] GetComparableMembers(Type type) |
| 12 | 対象外 | — | { |
| 13 | 実行済み | 369 | return MemberCache.GetOrAdd(type, static t => |
| 14 | 実行済み | 469 | t.GetProperties(BindingFlags.Public | BindingFlags.Instance) |
| 15 | 実行済み | 133 | .Where(property => property.GetMethod is not null) |
| 16 | 実行済み | 133 | .Where(property => property.GetIndexParameters().Length == 0) |
| 17 | 実行済み | 133 | .Where(property => property.GetCustomAttribute<CompareIgnoreAttribute>() is null) |
| 18 | 実行済み | 130 | .Select(property => new ComparableMember(property)) |
| 19 | 実行済み | 469 | .Concat(t.GetFields(BindingFlags.Public | BindingFlags.Instance) |
| 20 | 実行済み | 23 | .Where(field => field.GetCustomAttribute<CompareIgnoreAttribute>() is null) |
| 21 | 実行済み | 23 | .Select(field => new ComparableMember(field))) |
| 22 | 実行済み | 469 | .ToArray()); |
| 23 | 対象外 | — | } |
| 24 | 対象外 | — | |
| 25 | 対象外 | — | public static ComparableMember? GetCompareKeyMember(Type type) |
| 26 | 対象外 | — | { |
| 27 | 実行済み | 162 | return CompareKeyCache.GetOrAdd(type, static t => |
| 28 | 実行済み | 162 | { |
| 29 | 実行済み | 38 | var property = t.GetProperties(BindingFlags.Public | BindingFlags.Instance) |
| 30 | 実行済み | 78 | .FirstOrDefault(property => property.GetCustomAttribute<CompareKeyAttribute>() is not null); |
| 31 | 実行済み | 38 | if (property is not null) |
| 32 | 実行済み | 162 | { |
| 33 | 実行済み | 27 | return new ComparableMember(property); |
| 34 | 実行済み | 162 | } |
| 35 | 実行済み | 162 | |
| 36 | 実行済み | 11 | var field = t.GetFields(BindingFlags.Public | BindingFlags.Instance) |
| 37 | 実行済み | 16 | .FirstOrDefault(field => field.GetCustomAttribute<CompareKeyAttribute>() is not null); |
| 38 | 実行済み | 11 | return field is null ? null : new ComparableMember(field); |
| 39 | 実行済み | 162 | }); |
| 40 | 対象外 | — | } |
| 41 | 対象外 | — | } |
| 42 | 対象外 | — | |
| 43 | 対象外 | — | internal sealed class ComparableMember |
| 44 | 対象外 | — | { |
| 45 | 対象外 | — | private readonly PropertyInfo? _property; |
| 46 | 対象外 | — | private readonly FieldInfo? _field; |
| 47 | 対象外 | — | |
| 48 | 実行済み | 157 | public ComparableMember(PropertyInfo property) |
| 49 | 対象外 | — | { |
| 50 | 実行済み | 157 | _property = property; |
| 51 | 実行済み | 157 | Name = property.Name; |
| 52 | 実行済み | 157 | MemberType = property.PropertyType; |
| 53 | 実行済み | 157 | } |
| 54 | 対象外 | — | |
| 55 | 実行済み | 23 | public ComparableMember(FieldInfo field) |
| 56 | 対象外 | — | { |
| 57 | 実行済み | 23 | _field = field; |
| 58 | 実行済み | 23 | Name = field.Name; |
| 59 | 実行済み | 23 | MemberType = field.FieldType; |
| 60 | 実行済み | 23 | } |
| 61 | 対象外 | — | |
| 62 | 実行済み | 1510 | public string Name { get; } |
| 63 | 対象外 | — | |
| 64 | 実行済み | 2336 | public Type MemberType { get; } |
| 65 | 対象外 | — | |
| 66 | 対象外 | — | public object? GetValue(object instance) => |
| 67 | 実行済み | 1545 | _property is not null ? _property.GetValue(instance) : _field!.GetValue(instance); |
| 68 | 対象外 | — | } |