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

loresoft / FluentCommand / 8850661434

26 Apr 2024 03:30PM UTC coverage: 54.48% (+2.6%) from 51.881%
8850661434

push

github

pwelter34
update debug settings

1152 of 2717 branches covered (42.4%)

Branch coverage included in aggregate %.

3682 of 6156 relevant lines covered (59.81%)

701.76 hits per line

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

81.25
/src/FluentCommand/DisposableBase.cs
1
namespace FluentCommand;
2

3
/// <summary>
4
/// A base class that implements <see cref="IDisposable"/>
5
/// </summary>
6
public abstract class DisposableBase
7
    : IDisposable
8
#if NETCOREAPP3_0_OR_GREATER
9
    , IAsyncDisposable
10
#endif
11
{
12
    private int _disposeState;
13

14
    /// <summary>
15
    /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
16
    /// </summary>
17
    public void Dispose()
18
    {
19
        Dispose(true);
207✔
20
        GC.SuppressFinalize(this);
207✔
21
    }
207✔
22

23
    /// <summary>
24
    /// Releases unmanaged and - optionally - managed resources
25
    /// </summary>
26
    /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
27
    protected void Dispose(bool disposing)
28
    {
29
        // set state to disposing
30
        if (Interlocked.CompareExchange(ref _disposeState, 1, 0) != 0)
366✔
31
            return;
126✔
32

33
        if (disposing)
240✔
34
            DisposeManagedResources();
207✔
35

36
        DisposeUnmanagedResources();
240✔
37

38
        // set state to disposed
39
        Interlocked.Exchange(ref _disposeState, 2);
240✔
40
    }
240✔
41

42
    /// <summary>
43
    /// Throws <see cref="ObjectDisposedException"/> if this instance is disposed.
44
    /// </summary>
45
    protected void AssertDisposed()
46
    {
47
        if (_disposeState != 0)
1,395!
48
            throw new ObjectDisposedException(GetType().FullName);
×
49
    }
1,395✔
50

51
    /// <summary>
52
    /// Get the disposed state of the object.
53
    /// </summary>
54
    protected bool IsDisposed => _disposeState != 0;
×
55

56
    /// <summary>
57
    /// Disposes the managed resources.
58
    /// </summary>
59
    protected virtual void DisposeManagedResources()
60
    { }
9✔
61

62
    /// <summary>
63
    /// Disposes the unmanaged resources.
64
    /// </summary>
65
    protected virtual void DisposeUnmanagedResources()
66
    { }
240✔
67

68
#if NETCOREAPP3_0_OR_GREATER
69
    /// <summary>
70
    /// Disposes the asynchronous.
71
    /// </summary>
72
    /// <returns></returns>
73
    public async ValueTask DisposeAsync()
74
    {
75
        // set state to disposing
76
        if (Interlocked.CompareExchange(ref _disposeState, 1, 0) != 0)
471!
77
            return;
×
78

79
        await DisposeResourcesAsync();
471✔
80

81
        // set state to disposed
82
        Interlocked.Exchange(ref _disposeState, 2);
471✔
83
    }
471✔
84

85
    /// <summary>
86
    /// Disposes the managed resources.
87
    /// </summary>
88
    protected virtual ValueTask DisposeResourcesAsync()
89
    {
90
        return ValueTask.CompletedTask;
×
91
    }
92
#endif
93

94
    /// <summary>
95
    /// Releases unmanaged resources and performs other cleanup operations before the
96
    /// <see cref="DisposableBase"/> is reclaimed by garbage collection.
97
    /// </summary>
98
    ~DisposableBase()
99
    {
100
        Dispose(false);
159✔
101
    }
318✔
102
}
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