net9.0-desktop : making platform specific calls? #19726
-
My apologies for asking what I'm guessing is a very basic question. When targeting net9.0-desktop, how do we make platform specific (MacOS, Linux, or WPF) calls? Conditional compilation via compiler directives does not work in VisualStudio or Rider: namespace UnoApp9;
#if DESKTOP
using Uno;
#if MACOS
using Fondation;
#elif WINDOWS
using Pizza;
#elif LINUX
using Cheese;
#endif
#endif
public sealed partial class MainPage : Page ... which I guess is expected? But if they don't work, I'm not sure how other historical approaches (Runtime Platform Detection, Using [DllImport] attribute, abstraction, bait-and-switch) would work either. I'm really interesting in porting to MacOS desktop and Windows Desktop but there's a handful of platform specific things I'd like to be sure are working. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Indeed, compiler constants do not work here as there is only one target framework |
Beta Was this translation helpful? Give feedback.
-
Thanks, @MartinZikmund |
Beta Was this translation helpful? Give feedback.
-
@MartinZikmund : Re-opening this dialog because I'm pretty sure I'm stuck. I'm trying to implement a work around for the missing WebView2.CoreWebView2.PrintAsync() functionality. I have it working for everything but Desktop+MacOs (haven't tried testing in Linux yet). To get it working in Android and iOS, I had to:
I highly suspect that WebView2 for MacOS Desktop uses Safari under the covers as there's a very specific bug I only see when using However, as far as I know, Would you have any guidance here to point me in the right direction? |
Beta Was this translation helpful? Give feedback.
Indeed, compiler constants do not work here as there is only one target framework
-desktop
== a single set of binaries. You can do runtime platform-specific checks though, usingOperatingSystem.IsLinux()
etc.