-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Open
Milestone
Description
Android requires a one-to-many mapping from a Java class (string in TypeMapAttribute) to .NET types. A workaround is possible to make this mapping via an intermediate type with attributes pointing to the mapped types. However, to make the types trimmable, the type map needs to support having duplicate TypeMapAttribute's with identical first two parameters (java class string and .NET target type) but with different trimTarget types.
[assembly: TypeMap<UsedTypeMap>("DuplicateString", typeof(SameTargetType), typeof(DifferentTrimTarget1))]
[assembly: TypeMap<UsedTypeMap>("DuplicateString", typeof(SameTargetType), typeof(DifferentTrimTarget2))]
public class Program
{
public static void Main()
{
var mappedTypes = System.Runtime.InteropServices.TypeMapping.GetOrCreateExternalTypeMapping<UsedTypeMap>()["DuplicateString"].GetCustomAttributes(typeof(MappingAttribute));
}
}
class DifferentTrimTarget1
{
}
class DifferentTrimTarget2
{
}
[Mapping(typeof(DifferentTrimTarget1))]
[Mapping(typeof(DifferentTrimTarget2))]
class SameTargetType
{
}
class UsedTypeMap { }
This can be worked around in the meantime by omitting the trim target and rooting the target type always.
AaronRobinsonMSFT
Metadata
Metadata
Assignees
Type
Projects
Status
No status