• 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

42.86
/NetFabric.Reflection/Reflection/IndexableInfo.cs
1
using System;
2
using System.Reflection;
3

4
namespace NetFabric.Reflection;
5

6
/// <summary>
7
/// Contains information about methods and properties that will be used to enumerate a given type using the indexer.
8
/// </summary>
9
public class IndexableInfo
10
{
11
    /// <summary>
12
    /// Information on the indexer with a single parameter of type <see cref="int"/>.
13
    /// </summary>
14
    public PropertyInfo Indexer { get; }
4✔
15
    
16
    /// <summary>
17
    /// Information on the indexer with a single parameter of type <see cref="int"/>.
18
    /// </summary>
19
    public PropertyInfo CountOrLength { get; }
4✔
20

21
    internal IndexableInfo(PropertyInfo indexer, PropertyInfo countOrLength)
4✔
22
    {
23
        Indexer = indexer;
4✔
24
        CountOrLength = countOrLength;
4✔
25
    }
4✔
26

27
    public object? InvokeIndexer(object instance, int index)
28
    {
29
        try
30
        {
31
            return Indexer.GetValue(instance, new object[] { index });
×
32
        }
33
        catch (TargetInvocationException exception)
×
34
        {
35
            throw new EnumerationException($"Unhandled exception in {Indexer.DeclaringType!.Name}.{Indexer!.Name}", exception.InnerException!);
×
36
        }
37
    }
×
38

39
    public int InvokeCountOrLength(object instance)
40
    {
41
        try
42
        {
43
            return (int)CountOrLength.GetValue(instance);
×
44
        }
45
        catch (TargetInvocationException exception)
×
46
        {
47
            throw new EnumerationException($"Unhandled exception in {CountOrLength.DeclaringType!.Name}.{CountOrLength!.Name}", exception.InnerException!);
×
48
        }
49
    }
×
50
}
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