Tips for solving non-trivial breaking changes when upgrading from previous versions.
- Exported functions (
#[ffi_function]
) don't need to specify#[no_mangle]
orextern "C"
anymore as these will be added automatically. - Exported types (
#[ffi_type]
) must not specify#[repr(...)]
anymore as we will handle that. If you need custom attributes you can, for example, do#[ffi_type(transparent)]
or#[ffi_type(packed)]
. - In service definitions, providing a
prefix
is generally not needed anymore. - Service methods that return void (
()
) can now be used without a#[ffi_service_method]
annotation. On a Rust panic they will silently return. If this is not acceptable you must returnResult
or specify a different panic behavior via that attribute. #[ffi_type(patterns(ffi_error))]
is now#[ffi_type(error)]
.- The concept of overload writers has been removed entirely.
AsciiPointer
is now calledCStrPointer
, since it can contain non-ASCII data (e.g., when called from C#).- We fixed capitalization in some backends, e.g., a
Sliceu8
is nowSliceU8
. - When using
InventoryBuilder
you should call.validate().inventory()
now. - To override visibility for all fields:
- Previously you had to
#[ffi_type(visibility(_ = "public"))]
- Now you do
#[ffi_type(visibility(_all = "public"))]
- Previously you had to
- Surrogates now work through the
Surrogate<T, L>
type.- Previously you needed to specify
#[ffi_surrogates(some_field = "some_foreign_type")]
- Instead, you now make
some_field
of typeSurrogate<Foreign, Local>
- Previously you needed to specify
- Setting alignment on types is not supported anymore (for now). You should also stop using alignment on earlier versions as various backends didn't translate that properly.
- Backend-related testing functions were moved into an internal
tests
project, as the code was mostly specific to our project needs anyway.
- Unity support was dropped due to a lack of bandwidth on my side and compat issues, compare this issue. If you need Unity support you should stick with 0.14, wait for Unity to support .NET 8.0, or fork the C# backend. For the latter option I happily help you get started, please post a comment in the linked issue.
If you used the C#DotNet
orUnity
overload writer, these helpers now take their own configuration where appropriate. If you previously only didDotNet::new()
this becameDotNet::new_built()
.- The concept of overload writers was removed entirely.
- The minimum supported C# version was bumped to 8.0
- We're using
LibraryImport
instead ofDLLImport
now, which should be significantly faster - The concept of
Safe
vsUnsafe
bindings was removed. Everything isunsafe
now. This means in your.csproj
you should set<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
. This greatly simplified some code, and if you haven't used unsafe before you'll get a massive speed boost. If you shipped safe bindings to customers without a.csproj
file so far, you should now ship them with a.csproj
file that enables that flag instead.
- Removed
inventory!
macro- You now just write a regular function returning an
Inventory
- See the reference project for details
- You now just write a regular function returning an
- Deprecated Python CFFI backend, replace with Python CTypes backend.
- Might require changing some invocations. Please see
reference_project.py
.
- Might require changing some invocations. Please see
- Renamed attributes of
#[ffi_service_method]
once more, no behavior changed:wrap
is nowon_panic
direct
isreturn_default
raw
isundefined_behavior
- Changed behavior of
#[ffi_service_method]
#[ffi_service_method(direct)]
is now#[ffi_service_method(wrap = "direct")]
- C# backend switched constructors to static methods
- Wherever you used
new Service(x)
now useService.NewWith(x)
(or similar).
- Wherever you used
- C# backend split into
DotNet
andUnity
. If methods are missing:- Add
.add_overload_writer(DotNet::new())
toGenerator
. - Consider adding
.add_overload_writer(Unity::new())
when targeting Unity
- Add
- Replaced most
pattern!
macros with#[pattern]
attributes, see individual pattern documentation for details. - Added type hints support, upgraded minimum supported Python version to 3.7 [no workaround]