<MethodInstantiation> Element (.NET Native)

Applies runtime reflection policy to a constructed generic method. See important info in Remarks.

Syntax

<MethodInstantiation Name="method_name"
                     Signature="method_signature"
                     Arguments="method_arguments"
                     Browse="policy_type"
                     Dynamic="policy_type" />

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute Attribute type Description
Name General Required attribute. Specifies the method name.
Signature General Optional attribute. Specifies named parameters of the method. Multiple named parameters are separated by commas. The Signature attribute is used to differentiate overloaded methods.
Arguments General Required attribute. Specifies the generic type arguments. If multiple arguments are present, they are separated by commas.
Browse Reflection Optional attribute. Controls querying for information about or enumerating a method but does not enable any dynamic invocation at run time.
Dynamic Reflection Optional attribute. Controls runtime access to a constructor or method to enable dynamic programming. This policy ensures that a member can be invoked dynamically at run time.

Name attribute

Value Description
method_name The method name. The type of the method is defined by the parent <Type> or <TypeInstantiation> element.

Signature attribute

Value Description
method_signature Specifies the named parameters of the method. If multiple parameters are present, they are separated by commas.

Arguments attribute

Value Description
method_arguments Specifies the generic type arguments. If multiple arguments are present, they are separated by commas. Each argument must consist of the fully qualified type name.

All other attributes

Value Description
policy_setting The setting to apply to this policy type for the method. Possible values are Auto, Excluded, Included, and Required. For more information, see Runtime Directive Policy Settings.

Child Elements

None.

Parent Elements

Element Description
<Type> Applies reflection policy to a type and all its members.
<TypeInstantiation> Applies reflection policy to a constructed generic type and all its members.

Remarks

The <MethodInstantiation> element overrides the runtime reflection policy of its corresponding open generic method.

When you encounter a System.Reflection.MissingRuntimeArtifactException exception ('Cannot retrieve a MethodInfo for this delegate because the method it targeted [...] was not enabled for metadata using the Dynamic attribute.'), the message provides a url for you to visit, and that url takes you to the MissingMetadataException troubleshooter. Fill in the details in the I reflect on section, and then use the markup that's generated in the Preview section.

If there are no generic parameters, then leave Comma-separated generic arguments to instantiate the method blank. In that case you can disregard the WARNING: The directive below is not complete yet in the Preview section; and the MethodInstantiation@Arguments attribute will be empty in the Preview, by design. As documented above, the Arguments attribute specifies the generic type arguments, and not method parameters.

See also