[WIP] Embed .NET (Core) in your D app

evilrat evilrat666 at gmail.com
Tue Feb 11 07:05:28 UTC 2020


On Tuesday, 11 February 2020 at 05:41:21 UTC, Jonathan Marler 
wrote:
>
> I started a project just over a month ago that fills the same 
> role:
>
> https://github.com/marler8997/clrbridge
>
> I started with the dflat project found here 
> (https://github.com/thewilsonator/dflat) and eventually changed 
> the design to create this new one.  I'll have to take a look at 
> your project and see if we can share/mutually benefit from our 
> approaches.

Yes, when I started it I was looking at dflat first, but 
instantly rejected it because of complexity and extra steps 
involved.

Your project seems to aim to be a complete solution, it looks far 
more robust but also much more complex.

While my library is basically a .NET Core API wrapper over 5 
native functions with extra 7 or so C# functions. No external 
tools are required, no patching, no intermediate steps. Just 
provide type declarations in D and that's it.
The most complex part is IL generator that weaves in custom 
marshaling logic that avoids current CLR implementation 
limitations (which may or may not be resolved in .NET 5), but it 
also means delegates generated on demand, and the next biggest 
chunk is huge D template to glue this together and hide memory 
management details.
I also keep it pretty independent, one is free to make their own 
wrapper generator, also feel free to use delegate emitter library 
in other projects or even languages.

When designing it I tried to keep it minimalistic as possible, I 
also think it nicely fits the position as a temporary solution 
until I do real compiler (if ever). Meanwhile it might be useful 
on occasion to call few methods here and there.


More information about the Digitalmars-d mailing list