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

loresoft / FluentCommand / 15638433985

13 Jun 2025 03:39PM UTC coverage: 54.709% (+0.5%) from 54.174%
15638433985

push

github

pwelter34
misc updates

1692 of 3584 branches covered (47.21%)

Branch coverage included in aggregate %.

114 of 156 new or added lines in 9 files covered. (73.08%)

15 existing lines in 5 files now uncovered.

4291 of 7352 relevant lines covered (58.37%)

233.09 hits per line

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

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

3
/// <summary>
4
/// Provides a base implementation of the <see cref="IDisposable"/> pattern, including support for asynchronous disposal on supported platforms.
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
    /// Releases all resources used by the current instance of the <see cref="DisposableBase"/> class.
16
    /// </summary>
17
    public void Dispose()
18
    {
19
        Dispose(true);
69✔
20
        GC.SuppressFinalize(this);
69✔
21
    }
69✔
22

23
    /// <summary>
24
    /// Releases the unmanaged resources used by the object and, optionally, releases the managed resources.
25
    /// </summary>
26
    /// <param name="disposing">
27
    /// <c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.
28
    /// </param>
29
    protected void Dispose(bool disposing)
30
    {
31
        // set state to disposing
32
        if (Interlocked.CompareExchange(ref _disposeState, 1, 0) != 0)
81!
UNCOV
33
            return;
×
34

35
        if (disposing)
81✔
36
            DisposeManagedResources();
69✔
37

38
        DisposeUnmanagedResources();
81✔
39

40
        // set state to disposed
41
        Interlocked.Exchange(ref _disposeState, 2);
81✔
42
    }
81✔
43

44
    /// <summary>
45
    /// Throws an <see cref="ObjectDisposedException"/> if this instance has already been disposed.
46
    /// </summary>
47
    protected void AssertDisposed()
48
    {
49
        if (_disposeState != 0)
477!
50
            throw new ObjectDisposedException(GetType().FullName);
×
51
    }
477✔
52

53
    /// <summary>
54
    /// Gets a value indicating whether this instance has been disposed.
55
    /// </summary>
56
    protected bool IsDisposed => _disposeState != 0;
×
57

58
    /// <summary>
59
    /// Releases managed resources. Override this method to dispose managed resources in derived classes.
60
    /// </summary>
61
    protected virtual void DisposeManagedResources()
62
    { }
3✔
63

64
    /// <summary>
65
    /// Releases unmanaged resources. Override this method to dispose unmanaged resources in derived classes.
66
    /// </summary>
67
    protected virtual void DisposeUnmanagedResources()
68
    { }
81✔
69

70
#if NETCOREAPP3_0_OR_GREATER
71
    /// <summary>
72
    /// Asynchronously releases all resources used by the current instance of the <see cref="DisposableBase"/> class.
73
    /// </summary>
74
    /// <returns>A <see cref="ValueTask"/> that represents the asynchronous dispose operation.</returns>
75
    public async ValueTask DisposeAsync()
76
    {
77
        // set state to disposing
78
        if (Interlocked.CompareExchange(ref _disposeState, 1, 0) != 0)
163!
79
            return;
×
80

81
        await DisposeResourcesAsync();
163✔
82

83
        // set state to disposed
84
        Interlocked.Exchange(ref _disposeState, 2);
163✔
85

86
        GC.SuppressFinalize(this);
163✔
87
    }
163✔
88

89
    /// <summary>
90
    /// Asynchronously releases managed resources. Override this method to asynchronously dispose managed resources in derived classes.
91
    /// </summary>
92
    /// <returns>A <see cref="ValueTask"/> that represents the asynchronous dispose operation.</returns>
93
    protected virtual ValueTask DisposeResourcesAsync()
94
    {
95
        return ValueTask.CompletedTask;
×
96
    }
97
#endif
98

99
    /// <summary>
100
    /// Finalizes an instance of the <see cref="DisposableBase"/> class.
101
    /// Releases unmanaged resources and performs other cleanup operations before the object is reclaimed by garbage collection.
102
    /// </summary>
103
    ~DisposableBase()
104
    {
105
        Dispose(false);
12✔
106
    }
24✔
107
}
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