Language

UnsafeAccessorTypeAttribute(String) Constructor

Definition

Instantiates an UnsafeAccessorTypeAttribute providing access to a type supplied by typeName.

public:
 UnsafeAccessorTypeAttribute(System::String ^ typeName);
public UnsafeAccessorTypeAttribute(string typeName);
new System.Runtime.CompilerServices.UnsafeAccessorTypeAttribute : string -> System.Runtime.CompilerServices.UnsafeAccessorTypeAttribute
Public Sub New (typeName As String)

Parameters

typeName
String

A fully qualified or partially qualified type name.

Remarks

typeName is expected to follow the same rules as if it were being passed to <see name="Type.GetType(String)"></see>. When unbound generics are involved they should follow the IL syntax of referencing a type or method generic variables using the syntax of !N or !!N respectively, where N is the zero-based index of the generic parameters. The generic rules defined for UnsafeAccessorAttribute apply to this attribute as well, meaning the arity and type of generic parameter must match the target type.

This attribute only has behavior on parameters or return values of methods marked with UnsafeAccessorAttribute.

This attribute should only be applied to parameters or return types of methods that are typed as follows:

  • References should be typed as object.
  • Byref arguments should be typed with in, ref, or out to object.
  • Unmanaged pointers should be typed as void*.
  • Byref arguments to reference types or arrays should be typed with in, ref, or out to object.
  • Byref arguments to unmanaged pointer types should be typed with in, ref, or out to void*.
Value types are not supported.

Due to lack of variance for byrefs, returns involving byrefs are not supported. This specifically means that accessors for fields of inaccessible types are not supported.

Applies to