Skip to content

[MonoAPI] embedding API testing and API headers quality of life improvements #64456

Closed
@lambdageek

Description

@lambdageek

The current mono public embedding API headers are awkward to work with both for runtime developers and for embedding hosts that wish to dynamically load the runtime:

  • The API headers are in the same directory as the Mono implementation and the internal Mono headers, making it difficult to understand which headers constitute the public API surface without reading the cmake files. Additionally, other runtimes implementing the mono embedding API cannot easily share the headers.
  • The API headers declare mono API functions with MONO_API return_type function_name (args...), which is reasonable for embedding hosts that link to the runtime at compile time, but are not suitable for hosts that use late binding (dlopen+dlsym) to access the mono symbols. We should reorganize the headers to support late binding. (One idea: define API functions as MONO_API(return_type, function_name, (args...)) and allow users of the headers to re-define the MONO_API macro and include the header multiple times. That would allow C compile-time "code generation" of typedefs and dlsym boilerplate.
  • One client of the new headers would be a testsuite of the embedding API. Previously in github.com/mono/mono, the tests (src/mono/mono/tests/libtest.c) had to duplicate the API function signatures just to declare the function pointers storing the dynamically loaded symbols.

Tasks:

  • move public API headers to src/native/include/mono-2.0 (ie: src/native/include/mono-2.0/mono/metadata/object.h src/native/include/mono-2.0//mono/mini/jit.h etc) [build] Move Mono API headers under src/native/public #64569
  • Define MONO_API_FUNCTION(return_type,name,args_sig) and factor the public headers into "implementation details" headers; move type definitions to separate details headers from function definitions; allow the function definitions headers to be included multiple times and to re-define MONO_API_FUNCTION (r,n,a) [MonoAPI] Split type and function headers, add MONO_API_FUNCTION macro #65446
  • Move the libtest.c and existing embedding API testing code from src/mono/mono/tests to src/tests/Interop/MonoAPI and run the tests on desktop mono configurations. Includes switching the tests to use the new MONO_API_FUNCTION late binding approach. [tests] Add MonoApi runtime tests #65221

Metadata

Metadata

Assignees

Labels

area-VM-meta-monotrackingThis issue is tracking the completion of other related issues.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions