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

NetFabric / NetFabric.CodeAnalysis / 6130084901

09 Sep 2023 09:14AM UTC coverage: 83.158% (+0.2%) from 82.932%
6130084901

push

github

web-flow
Fixes (#27)

227 of 266 branches covered (0.0%)

Branch coverage included in aggregate %.

661 of 661 new or added lines in 31 files covered. (100.0%)

642 of 779 relevant lines covered (82.41%)

18.46 hits per line

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

36.0
/NetFabric.Reflection/Reflection/AsyncEnumeratorInfo.cs
1
using System;
2
using System.Reflection;
3
using System.Threading.Tasks;
4

5
namespace NetFabric.Reflection;
6

7
/// <summary>
8
/// Contains information about methods and properties of an enumerator that ´await foreach´ will use to enumerate a given type.
9
/// </summary>
10
public class AsyncEnumeratorInfo
11
{
12
    /// <summary>
13
    /// Information on the property that 'await foreach' will use to get the value of current item.
14
    /// </summary>
15
    public PropertyInfo Current { get; }
9✔
16
    
17
    /// <summary>
18
    /// Information on the method that 'await foreach' will use to iterate to the next item.
19
    /// </summary>
20
    public MethodInfo MoveNextAsync { get; }
9✔
21
    
22
    /// <summary>
23
    /// Information on the method that 'await foreach' will use to dispose the enumerator, if it's disposable.
24
    /// </summary>
25
    /// <remarks>
26
    /// To be considered disposable, the enumerator has to implement <see cref="System.IAsyncDisposable"/>,
27
    /// except if it's a by reference like value type (ref struct) which only needs to have a public
28
    /// method named 'DisposeAsync'.
29
    /// </remarks>
30
    public MethodInfo? DisposeAsync { get; init; }
18✔
31
    
32
    /// <summary>
33
    /// Indicates if 'await foreach' considers the enumerator to be a value type.
34
    /// </summary>
35
    public bool IsValueType { get; init; }    
16✔
36
    
37
    /// <summary>
38
    /// Indicates if 'await foreach' considers the enumerator to be of type <see cref="System.Collections.Generic.IAsyncEnumerator&lt;&gt;"/>.
39
    /// </summary>
40
    public bool IsAsyncEnumeratorInterface { get; init; }    
9✔
41

42
    internal AsyncEnumeratorInfo(PropertyInfo current, MethodInfo moveNextAsync)
9✔
43
    {
44
        Current = current;
9✔
45
        MoveNextAsync = moveNextAsync;
9✔
46
    }
9✔
47

48
    public object? GetValueCurrent(object instance)
49
    {
50
        try
51
        {
52
            return Current.GetValue(instance);
×
53
        }
54
        catch (TargetInvocationException exception)
×
55
        {
56
            throw new EnumerationException($"Unhandled exception in {Current.DeclaringType!.Name}.Current.", exception.InnerException!);
×
57
        }
58
    }
×
59

60
    public ValueTask<bool> InvokeMoveNextAsync(object instance)
61
    {
62
        try
63
        {
64
            return (ValueTask<bool>)MoveNextAsync.Invoke(instance, null)!;
×
65
        }
66
        catch (TargetInvocationException exception)
×
67
        {
68
            throw new EnumerationException($"Unhandled exception in {MoveNextAsync.DeclaringType!.Name}.MoveNextAsync().", exception.InnerException!);
×
69
        }
70
    }
×
71

72
    public ValueTask InvokeDisposeAsync(object instance)
73
    {
74
        if (DisposeAsync is null)
×
75
            throw new NotSupportedException("DisposeAsync() is not defined.");
×
76

77
        try
78
        {
79
            return (ValueTask)DisposeAsync.Invoke(instance, null)!;
×
80
        }
81
        catch (TargetInvocationException exception)
×
82
        {
83
            throw new EnumerationException($"Unhandled exception in {DisposeAsync.DeclaringType!.Name}.DisposeAsync().", exception.InnerException!);
×
84
        }
85
    }
×
86
}
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