Cross-platform object-oriented interaction between C# and C++

RU / Day 2 / 14:00 / Track 2

P/Invoke is very easy to use, but, sadly, works only with libraries providing C-style functions. As for object-oriented interaction with native code, it is usually implemented by means of C++/CLI which isn't compatible with .NET Core (yet) and non-Windows platforms (at all).

As .NET moves to other platforms, we encounter a problem of interaction with non-manageable part of application, which needs to be solved somehow.

In this talk, we'll see a solution which:

  • enables transparent two-way connection between C++ and C# on the level of interfaces which both C# and C++ classes can implement;
  • allows you to control memory usage through reference counting;
  • doesn't reinvent the wheel, but rather uses technologies and principles, tried and tested by the time and hundreds of applications, in a not-so-standard manner;
  • is successfully being used now in the Avalonia project for the C#<->C++<->Objective-C interactions without being bound to intricately-patched runtimes like Xamarin.Mac.