Help with .NET UNO Bridges for LibreOffice

Ritobroto Mukherjee ritobroto04 at gmail.com
Sat Aug 10 13:19:28 UTC 2024


Hello everyone,

I'm a GSoC contributor this year, working on updating the .NET UNO
bridge to support non-Windows platforms and the latest .NET versions.
I've submitted a series of patches, which can be found here:
https://gerrit.libreoffice.org/q/%22.NET+Bindings%22

I have completed netmaker for producing C# stubs from IDL files, and
made required Makefile changes to build and test .NET code.

While working on the next step, the bridge, I'm facing a few challenges
and I'd appreciate it if someone could help me in understanding the
architecture and the implementation for other existing language
bindings like Java.

The GSoC project involves two variants of the bridge: a "native" bridge
and a "managed" bridge, both planned with separate goals in mind. The
native bridge aims to provide consistent behavior with existing
bridges, by reusing existing native code, and should be easier to
extended with in-process bridging support. The managed bridge, on the
other hand, will be portable and easier to consume since it does not
require a complete LO installation to run.

1) Managed Bridge

The managed bridge is a completely C# reimplementation of the bridge,
including the URP protocol, and is based on the ridljar/ and binaryurp/
modules. It is less fleshed out right now, only containing
implementations of some of the interfaces and services. I'm trying to
understand the Java UNO bridge in ridljar/ and the C++ binaryurp/
modules so I could port them to C#, and they include a pair of classes
named JobQueue and ThreadPool in there that I'm having trouble
understanding what role they play and how they handle threads and jobs.

I would really appreciate it if someone can explain how they work.

2) Native Bridge

The native bridge uses P/Invoke to reuse the existing C++ bootstrap and
bridge code via C#. It is at a stage where parameter-less functions and
interface attribute getters are mostly implemented. However, I am
facing challenges with marshaling and unmarshaling various types of
parameters between C# and native memory, including complex types such
as arrays and structs, and managing object lifetimes (acquire and
release calls).

Should arrays be pinned or copied to native memory, and same for
structs? Would lumping all parameter data in a single block of memory
be better?

These are the relevant patches:
.NET Bindings: Create nuget package for LO SDK
https://gerrit.libreoffice.org/c/core/+/170172

.NET Bindings: Progress on native bridge
https://gerrit.libreoffice.org/c/core/+/170916

Best regards,
Ritobroto


More information about the LibreOffice mailing list