• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NetFabric / NetFabric.CodeAnalysis / 6253798736

20 Sep 2023 08:33PM UTC coverage: 75.653% (-7.5%) from 83.158%
6253798736

Pull #28

github

aalmada
Fixes
Pull Request #28: Add IsIndexable

292 of 404 branches covered (0.0%)

Branch coverage included in aggregate %.

259 of 259 new or added lines in 15 files covered. (100.0%)

693 of 898 relevant lines covered (77.17%)

17.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.67
/NetFabric.Reflection/Reflection/TypeExtensions.IsIndexable.cs
1
using System;
2
using System.Diagnostics.CodeAnalysis;
3

4
namespace NetFabric.Reflection;
5

6
public static partial class TypeExtensions
7
{        
8
    public static bool IsIndexable(this Type type)
9
        => IsIndexable(type, out _, out _);
×
10

11
    public static bool IsIndexable(this Type type, [NotNullWhen(true)] out IndexableInfo? indexableInfo)
12
        => IsIndexable(type, out indexableInfo, out _);
×
13

14
    public static bool IsIndexable(this Type type,
15
        [NotNullWhen(true)] out IndexableInfo? indexableInfo,
16
        out IsIndexableError error)
17
    {
18
        var countOrLength = type.GetReadProperty(PublicInstance, NameOf.Count);
7✔
19
        countOrLength ??= type.GetReadProperty(PublicInstance, NameOf.Length);
7✔
20
        if (countOrLength is null || !countOrLength.PropertyType.IsIntegerType())
7✔
21
        {
22
            indexableInfo = default;
1✔
23
            error = IsIndexableError.MissingCountOrLength;
1✔
24
            return false;
1✔
25
        }
26

27
        var indexer = type.GetReadIndexer(PublicInstance, countOrLength.PropertyType);
6✔
28
        if (indexer is null)
6✔
29
        {
30
            indexableInfo = default;
2✔
31
            error = IsIndexableError.MissingIndexer;
2✔
32
            return false;
2✔
33
        }
34

35
        indexableInfo = new IndexableInfo(indexer, countOrLength);
4✔
36
        error = IsIndexableError.None;
4✔
37
        return true;
4✔
38
    }
39
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc