Struct OpaqueValue<T>
Represents an opaque value that can be passed to unmanaged code as nint.
Inherited Members
Namespace: DotNext.Runtime.InteropServices
Assembly: DotNext.Unsafe.dll
Syntax
[NativeMarshalling(typeof(OpaqueValueMarshaller<>))]
public readonly struct OpaqueValue<T> : IDisposable, IEquatable<OpaqueValue<T>> where T : notnull
Type Parameters
| Name | Description |
|---|---|
| T | The underlying type. |
Remarks
The opaque value can be used to pass the value from the managed code to the unmanaged code that keeps the callback to the managed code through the shim method marked as UnmanagedCallersOnlyAttribute.
Constructors
View SourceOpaqueValue(T?)
Creates a copy of the value or reference and makes it available from within the unmanaged code.
Declaration
public OpaqueValue(T? value)
Parameters
| Type | Name | Description |
|---|---|---|
| T | value | The value that can be accessed from the unmanaged code. |
Methods
View SourceDispose()
Releases the underlying storage for the value.
Declaration
public void Dispose()
Remarks
This method is not idempotent and should not be called twice.
Equals(OpaqueValue<T>)
Declaration
public bool Equals(OpaqueValue<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| OpaqueValue<T> | other |
Returns
| Type | Description |
|---|---|
| bool |
Equals(object)
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj |
Returns
| Type | Description |
|---|---|
| bool |
Overrides
View SourceGetHashCode()
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int |
Overrides
View SourceToString()
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string |
Overrides
Operators
View Sourceoperator ==(OpaqueValue<T>, OpaqueValue<T>)
Declaration
public static bool operator ==(OpaqueValue<T> left, OpaqueValue<T> right)
Parameters
| Type | Name | Description |
|---|---|---|
| OpaqueValue<T> | left | |
| OpaqueValue<T> | right |
Returns
| Type | Description |
|---|---|
| bool |
explicit operator delegate* unmanaged<nint, void>(OpaqueValue<T>)
Returns the cleanup action of the native calling convention for the current platform that releases the opaque value.
Declaration
[CLSCompliant(false)]
public static explicit operator delegate* unmanaged<nint, void>(OpaqueValue<T> opaque)
Parameters
| Type | Name | Description |
|---|---|---|
| OpaqueValue<T> | opaque | The opaque value. |
Returns
| Type | Description |
|---|---|
| delegate* unmanaged<nint, void> | The cleanup action that can be called from the unmanaged code. |
Remarks
The returned callback has the same effect as Dispose() method.
explicit operator delegate* unmanaged<nint, void>(OpaqueValue<T>)
Returns the cleanup action of the native calling convention for the current platform that releases the opaque value.
Declaration
[CLSCompliant(false)]
public static explicit operator delegate* unmanaged<nint, void>(OpaqueValue<T> opaque)
Parameters
| Type | Name | Description |
|---|---|---|
| OpaqueValue<T> | opaque | The opaque value. |
Returns
| Type | Description |
|---|---|
| delegate* unmanaged<nint, void> | The cleanup action that can be called from the unmanaged code. |
Remarks
The returned callback has the same effect as Dispose() method.
explicit operator delegate* unmanaged<nint, void>(OpaqueValue<T>)
Returns the cleanup action of the native calling convention for the current platform that releases the opaque value.
Declaration
[CLSCompliant(false)]
public static explicit operator delegate* unmanaged<nint, void>(OpaqueValue<T> opaque)
Parameters
| Type | Name | Description |
|---|---|---|
| OpaqueValue<T> | opaque | The opaque value. |
Returns
| Type | Description |
|---|---|
| delegate* unmanaged<nint, void> | The cleanup action that can be called from the unmanaged code. |
Remarks
The returned callback has the same effect as Dispose() method.
operator !=(OpaqueValue<T>, OpaqueValue<T>)
Declaration
public static bool operator !=(OpaqueValue<T> left, OpaqueValue<T> right)
Parameters
| Type | Name | Description |
|---|---|---|
| OpaqueValue<T> | left | |
| OpaqueValue<T> | right |
Returns
| Type | Description |
|---|---|
| bool |