Show / Hide Table of Contents

Struct OpaqueValue<T>

Represents an opaque value that can be passed to unmanaged code as nint.

Implements
IDisposable
IEquatable<OpaqueValue<T>>
Inherited Members
object.GetType()
object.Equals(object, object)
object.ReferenceEquals(object, object)
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 Source

OpaqueValue(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 Source

Dispose()

Releases the underlying storage for the value.

Declaration
public void Dispose()
Remarks

This method is not idempotent and should not be called twice.

View Source

Equals(OpaqueValue<T>)

Declaration
public bool Equals(OpaqueValue<T> other)
Parameters
Type Name Description
OpaqueValue<T> other
Returns
Type Description
bool
View Source

Equals(object)

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
object obj
Returns
Type Description
bool
Overrides
ValueType.Equals(object)
View Source

GetHashCode()

Declaration
public override int GetHashCode()
Returns
Type Description
int
Overrides
ValueType.GetHashCode()
View Source

ToString()

Declaration
public override string ToString()
Returns
Type Description
string
Overrides
ValueType.ToString()

Operators

View Source

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
View Source

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

Implements

IDisposable
IEquatable<T>

Extension Methods

BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, params ReadOnlySpan<T>)
Enumerator.Skip<TEnumerator, T>(ref TEnumerator, int)

See Also

UnmanagedCallersOnlyAttribute
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾