This is part of a series on Native AOT. Previous -- Top A few weeks ago I published some samples showing the use of Native AOT libraries from Rust. As I mentioned, the projection of .NET APIs to Rust requires quite a few ergonomic compromises. For example, the following line in C# is a call to the QuestPDF method to set the size of a page: ...
This is part of a series on Native AOT. Previous -- Top -- Next I have finally published a preview release of the Native AOT binding generator I've been working on. I wouldn't call it "production-ready" yet, but having the tool publicly available makes it more tangible and real. Folks can give it a try, and give feedback if they wish. There's a...
This is part of a series on Native AOT. Previous -- Top -- Next Developing with .NET often involves delegates, which we can think of as objects that represent things that are callable. For example: public static int count_files_with_e(string path) { return System.IO.Directory.GetFiles(path) .Where(x => x.Contains("e")) ...
This is part of a series on Native AOT. Previous -- Top -- Next So far in this blog series, I have been writing about Native AOT mostly in the context of libraries, discussing how things work at a fairly low level. For this post, I want to take a step back and look at the big picture, and the road ahead. Where is all this going? Why do we care...
This is part of a series on Native AOT. Previous -- Top -- Next As we have said, functions exported by a Native AOT library must follow the rules of C, and that means exceptions cannot be thrown. More specifically, it means that if we attempt to throw an exception past the Native AOT function boundary, the program will crash. C doesn't have...
This is part of a series on Native AOT. Previous -- Top -- Next In the previous chapter, we talked about GCHandle as a way to pass object references into native code. Let's dive a little deeper and talk about a problem that can happen with these object handles in the context of Native AOT. As we said in the previous chapter, the IntPtr from a...
This is part of a series on Native AOT. Previous -- Top -- Next So far, our examples have been very simplistic, using only integer types. Native AOT won't be very useful if we can never use objects. And we can. We just need to express them in terms of the conventions of C. Actually, the techniques for dealing with .NET objects in unmanaged...
This is part of a series on Native AOT. Previous -- Top -- Next Buckle up folks, this part of the ride gets a little bumpy. As of .NET 7, using Native AOT with static libraries is implemented, but is not yet considered a supported and documented feature. As mentioned previously, building a static library with Native AOT is straightforward. Just...
This is part of a series on Native AOT. Previous -- Top -- Next Native AOT produces libraries that can be called from any language that can call C. C# is one such language. Yes folks, that's right -- even though it is [probably] not useful, you can call into a Native AOT library from C# using P/Invoke: using System; using...
This is part of a series on Native AOT. Previous -- Top -- Next Rust has a really nice feature called raw-dylib, which allows calling external functions without linking at build time. Given the name of the shared library, Rust will dynamically load the library and lookup the function. (At the time of this writing, raw-dylib is supported only on...