I'm in the process of upgrading a Xamarin Native solution to run on .net 6 using SDK style multi-targetted projects.
As I understand it, there are two ways of writing platform-dependent code:
a) Code inside the appropriate platform directory (e.g. "iOS" or "MacCatalyst") is always compiled conditionally for that platform.
b) Code can be explicitly conditionally compiled via e.g., #if IOS.
Neither of these seems ideal when there is a large body of code that is shared between two platforms. In (a) the code is duplicated and in (b) the code is strewn with #ifs.
Is there a better way to share code between these two platforms?