dotnet / dotnet/reactive

[FR] CompositeDisposable - Remove accepts null values and returns false instead of throwing ArgumentNullException

Open
#1,775 1 comment 0 reactions 0 assignees View on GitHub
[area] Rx
Dominant language
C#
Stars
7.2k
Forks
798
PR merge metrics
No merged PRs in 30d

Description

#### Feature request

> Which next library version (i.e., patch, minor or major)?
- 16.2.0.0
> What are the platform(s), environment(s) and related component version(s)?
- Windows 10
> How commonly is this feature needed (one project, several projects, company-wide, global)?
- company-wide
> Please describe the feature.

The "Remove" method in the "CompositeDisposable" class accepts an IDispoable and returns a bool representing the success/failure of the operation.
If the parameter is null an ArgumentNullException is thrown. It would be better to return the value false instead of throwing an Exception.
If this is not possible, please add a "TryRemove" method that does not throw.

I would like to inherit the class and override the remove method, but the class is sealed and i do not want to maintain a branch just for this change.

something like:

```
///
/// Removes and disposes the first occurrence of a disposable from the .
///
/// Disposable to remove.
/// true if found; false otherwise.
/// is null.
public bool Remove(IDisposable item)
{
if (item == null)
{
return false;
}

lock (_gate)
[...]
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.