xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.48k stars 514 forks source link

MacOS CGDisplayStream bindings #11712

Open theimowski opened 3 years ago

theimowski commented 3 years ago

I originally posted this question on StackOverflow as per the wiki, however I've been suggested that this can actually be a valid GitHub issue asking about missing bindings.

I'd like to use CGDisplayStream API using Xamarin for MacOS, however it seems that there are no bindings for it yet.

My goal is to attempt to rewrite a PoC application using CGDisplayStream API from Swift to F#, so I thought it would be worth giving .net-6.0-macos target a try.

I browsed the code in https://github.com/xamarin/xamarin-macios/tree/main/src/CoreGraphics and didn't find any references to CGDisplayStream, the only place where I could find trace about this type was Wiki on Bindings: 1, 2, 3, but I'm not really sure how to read these pages.

  1. Are these bindings currently missing?
  2. If so, is that because there was no prior demand to incorporate those APIs, or is there something special about CGDisplayStream that makes it hard to bring into Xamarin?
  3. If it's just about lack of demand, could someone guide me on how to potentially contribute adding such bindings?
  4. Alternatively, is it even worth considering doing it the other way round, i.e. targeting .net-6.0 runtime instead of .net-6.0-macos and then trying invoking CGDisplayStream API via PInvoke? Or is that all not worth a hassle and I should just continue with a more native MacOS toolchain (Swift)?
spouliot commented 3 years ago

Are these bindings currently missing?

Yes.

If so, is that because there was no prior demand to incorporate those APIs

Yes.

If it's just about lack of demand, could someone guide me on how to potentially contribute adding such bindings?

Yes. See https://github.com/xamarin/xamarin-macios/wiki/How-to-Contribute

You can also ask such questions our discord (DotNetEvolution) #apple channel.

net6 support is also in preview, so a lot of change happens and the discord channel is the best place to discuss them.

Alternatively, is it even worth considering doing it the other way round

Not sure what you mean there. You can do p/invoke on both net-6.0 and net-6.0-macos.

IMO it's best to do proper bindings because they can be useful for others. It might also be easier since some API you'll bind will use native types that already exists in Xamarin.Mac (XM). IOW you could end up duplicating quite some code to make it work without XM.