Add constructor overloads to override AllowMultipleDisposeCalls and AllowMultipleDisposeAttempts #95
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements the enhancement requested in issue #35 by adding constructor overloads to the
Disposableclass that allow directly setting theAllowMultipleDisposeCallsandAllowMultipleDisposeAttemptsproperties without requiring inheritance.Changes Made
New Constructor Overloads: Added optional parameters
allowMultipleDisposeCallsandallowMultipleDisposeAttemptsto all existing constructors:Disposable(Action action, bool allowMultipleDisposeCalls = false, bool allowMultipleDisposeAttempts = false)Disposable(Disposal disposal, bool allowMultipleDisposeCalls = false, bool allowMultipleDisposeAttempts = false)Disposable(bool allowMultipleDisposeCalls, bool allowMultipleDisposeAttempts = false)Property Overrides: Override the virtual properties
AllowMultipleDisposeCallsandAllowMultipleDisposeAttemptsto return constructor-provided values when set, falling back to base implementation when not.Comprehensive Tests: Added 6 new unit tests covering all constructor scenarios:
Bug Fix: Updated
DisposalOrderTestto use .NET 8 instead of .NET 7 target frameworkBefore (Required Inheritance Workaround)
After (Direct Constructor Usage)
Test Results
All tests pass (11/11):
Backward Compatibility
This change is fully backward compatible. All existing code will continue to work exactly as before, with the new parameters defaulting to
false(maintaining current behavior).🤖 Generated with Claude Code
Resolves #35