|
36 | 36 | <Docs> |
37 | 37 | <typeparam name="TTypeMapGroup">The type of the type map group.</typeparam> |
38 | 38 | <summary>Represents an attribute that defines type mapping between a string and a type.</summary> |
39 | | - <remarks>To be added.</remarks> |
| 39 | + <remarks> |
| 40 | + <format type="text/markdown"><![CDATA[ |
| 41 | +
|
| 42 | +## Remarks |
| 43 | +
|
| 44 | +Types involved in unmanaged-to-managed interop operations can be referenced in a `TypeMapAttribute` assembly attribute that declares the external type system name, a target type, and optionally a "trim target" to determine if the target type should be included in the map. If the constructor that doesn't take a trim target is used, the entry is always emitted into the type map. |
| 45 | +
|
| 46 | +When an application is trimmed, an entry in the External Type Map is included when the "trim target" type is referenced in one of the following ways in reachable code: |
| 47 | +
|
| 48 | +- The argument to the `ldtoken` IL instruction. |
| 49 | +- The argument to the `unbox` IL instruction. |
| 50 | +- The argument to the `unbox.any` IL instruction. |
| 51 | +- The argument to the `isinst` IL instruction. |
| 52 | +- The argument to the `castclass` IL instruction. |
| 53 | +- The argument to the `box` instruction. (If the trimming tool can determine that this box doesn't escape and could be stack allocated, it can ignore this `box` instruction and any corresponding `unbox` or `unbox.any` instructions.) |
| 54 | +- The argument to the `mkrefany` instruction. |
| 55 | +- The argument to the `refanyval` instruction. |
| 56 | +- The argument to the `newarr` instruction. |
| 57 | +- The type of a method argument to the `newobj` instruction if it's a class type. |
| 58 | +- The owning type of an instance method argument to `call` or `ldftn`, or the owning type of any method argument to `callvirt` or `ldvirtftn`. (If the owning type is an interface and the trimming tool can determine that there's only one implementation of the interface, it's free to interpret the method token argument as though it's the method on the only implementing type.) |
| 59 | +- The generic argument to the <xref:System.Activator.CreateInstance%60%601> method. |
| 60 | +- Calls to <xref:System.Type.GetType%2A?displayProperty=nameWithType> with a constant string representing the type name. |
| 61 | +
|
| 62 | +Many of these instructions can be passed a generic parameter. In that case, the trimming tool should consider type arguments of instantiations of that type as having met one of these rules and include any entries with those types as "trim target" types. |
| 63 | +
|
| 64 | +> [!IMPORTANT] |
| 65 | +> Conflicting key/value mappings are not allowed. |
| 66 | +
|
| 67 | +> [!NOTE] |
| 68 | +> The underlying format of the produced maps is implementation-defined. Different .NET form factors might use different formats. Additionally, it's not guaranteed that the `TypeMapAttribute`, `TypeMapAssociationAttribute`, and `TypeMapAssemblyTargetAttribute` attributes are present in the final image after a trimming tool has been run. |
| 69 | +
|
| 70 | + ]]></format> |
| 71 | + </remarks> |
40 | 72 | </Docs> |
41 | 73 | <Members> |
42 | 74 | <Member MemberName=".ctor"> |
|
0 commit comments