I'm working on a Xamarin.Forms solution that uses a PCL library to share code between my Android and iOS projects. This has worked out great for the most part since most UI and logic code can be kept in one place. Of course, there are some platform-specific classes that I created and linked to the PCL using DependencyService
, and that's fine for most classes since code is significantly different between platforms (UI layout/appearance, for example).
However, there is one subset of classes that makes use of various namespaces that are unavailable for PCL projects (notably the System.Data namespace). To get around this restriction, I had to write a DependencyService for each of these classes. My concern is that the code between Android and iOS is exactly the same, minus one or two lines. The code is quite complex and I don't want to have to remember to update it twice when the need arises.
Is there a way I can reduce the amount of code duplicated between these two projects, considering that I cannot place the code into a PCL due to necessary namespaces which are unavailable?