There is custom library with a couple of reflection stuff in it. For some reasons at the moment I'm forced to set linker behavior to link 'Sdk and User Assemblies'. I've successfully configured linker via xml-config except of one point.
There is a place in our lib where we use obsolete member Newtonsoft.Json.JsonSerializer.Binder (actually property setter). I tried to configure linker this way:
<method name="set_Binder" />
<method signature="System.Void set_Binder(Newtonsoft.Json.SerializationBinder)" />
<type fullname="*" />
Any way - setter name / method signature / preserve all members don't do the thing - property setter omitted by linker. I guess it may be caused by this rule as per Xamarin docs:
When an assembly is linked, the following custom attribute types will be removed from all members:
Looks like member stripped by attributes at first and then accordingly to custom config. I can simply avoid stripping that setter by using this code:
var binder = Newtonsoft.Json.JsonSerializer.CreateDefault().Binder;
var serializer = Newtonsoft.Json.JsonSerializer.CreateDefault();
serializer.Binder = binder;
But it looks really dirty and hacky. I'd prefer to use some clear way to define such rule.
Is there any way to configure Android linker (actually on iOS enough to use
<type fullname="Newtonsoft.Json.JsonSerializer") for obsolete library methods in "clear" way without workaround like above?