Xamarin iOS 链接器导致 AutoMapper 问题

Pat*_*bee 3 automapper xamarin.ios ios xamarin-linker

我正在开发一个使用 AutoMapper 的 Xamarin 项目。当链接设置为“仅链接框架 SDK”时,初始化地图时出现以下错误

System.ArgumentNullException:值不能为空。参数名称:方​​法

异常并不多,调用堆栈也没有

AutoMapper.Mappers.ConvertMapper.MapExpression
AutoMapper.Execution.TypeMapPlanBuilder.ObjectMapperExpression
AutoMapper.Execution.TypeMapPlanBuilder.MapExpression
AutoMapper.Mappers.NullableSourceMapper.MapExpression
AutoMapper.Execution.TypeMapPlanBuilder.ObjectMapperExpression
AutoMapper.Execution.TypeMapPlanBuilder.MapExpression
AutoMapper.Execution.TypeMapPlanBuilder.MapExpression
AutoMapper .Execution.TypeMapPlanBuilder.CreatePropertyMapFunc
AutoMapper.Execution.TypeMapPlanBuilder.CreatePropertyMapFunc
AutoMapper.Execution.TypeMapPlanBuilder.TryPropertyMap
AutoMapper.Execution.TypeMapPlanBuilder.CreateAssignmentFunc
AutoMapper.Execution.TypeMapPlanBuilder.CreateMapperLambda
AutoMapper.TypeMap.Seal AutoMapper.MapperConfiguration.Seal
AutoMapper.MapperConfiguration..ctor
AutoMapper.MapperConfiguration..ctor AutoMapper.Mapper.Initialize

最初的阅读表明链接器只是从我们正在使用的某个类中删除了一些属性或方法。

但是,在注释掉大部分映射然后一次重新引入一个之后,我发现这个类当前导致了错误。

[Preserve]
internal class ItemBase : CareRecordItemBase
{
      [Preserve]
      public string Topic { get; set; }
    
      [Preserve]
      public string InPractice { get; set; }
    
      [Preserve]
      public string PrivateVal { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

如果我注释掉该InPractice属性,则不会抛出异常。这对我来说毫无意义。谁能解释为什么这可能是一个问题?

是否有更好的方法来诊断这些问题?

Iai*_*ith 5

基于帕特的回答:

  1. 添加一个 XML 文件LinkDescription.xml,您可以随意命名它。
  2. 添加此代码:
<linker> 
    <assembly fullname="mscorlib">
        <type fullname="System.Convert" preserve="All" />
    </assembly>
</linker>
Run Code Online (Sandbox Code Playgroud)
  1. 将文件的构建操作设置为 LinkDescription