While following this article on how to add in-app purchases to UWP apps, I came across a little quirk of conditional compilation directives. Initially, I started structuring my code like this:
Windows.ApplicationModel.Store.PurchaseResults result;
#if DEBUG
result = await Windows.ApplicationModel.Store.CurrentAppSimulator.RequestProductPurchaseAsync(Description);
#else
result = await Windows.ApplicationModel.Store.CurrentApp.RequestProductPurchaseAsync(Description);
#endif
But then I realised, that the code can be split over multiple lines such that the compile directive can sit halfway through the command; like this:
Windows.ApplicationModel.Store.PurchaseResults result = await
#if DEBUG
Windows.ApplicationModel.Store.CurrentAppSimulator.RequestProductPurchaseAsync(Description);
#else
Windows.ApplicationModel.Store.CurrentApp.RequestProductPurchaseAsync(Description);
#endif
The MSDN documentation of this can be found here.