Skip to content

[API Proposal]: Introduce SafeHandle.DangerousAddRef() #125265

@adamsitnik

Description

@adamsitnik

Background and motivation

From #124375 (comment):

addedRef is always true on return from DangerousAddRef (the argument is left over from thread abort hardeing that we do not care about anymore)

Because of this, the usage often looks like this:

bool ignored = false;
_parent.DangerousAddRef(ref ignored);

bool ignore = false;
parentHandle.DangerousAddRef(ref ignore);

API Proposal

namespace System.Runtime.InteropServices;

public abstract partial class SafeHandle
{
+   [EditorBrowsable(EditorBrowsableState.Never)]
    public void DangerousAddRef(ref bool success);
+   public void DangerousAddRef();
}

API Usage

handle.DangerousAddRef();

Risks

DangerousAddRef(ref bool success) is not abstract or virtual, so I can't see any.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions