Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Sep 14, 2025

πŸ“‹ Summary

This pull request implements a native library version of Platform.Data.Doublets using .NET NativeAOT (the modern successor to CoreRT) as requested in issue #40.

βœ… What's Implemented

  • New NativeAOT Project: csharp/Platform.Data.Doublets.NativeLibrary/

    • Modern NativeAOT configuration replacing deprecated CoreRT
    • C-style FFI exports with [UnmanagedCallersOnly] attributes
    • Thread-safe handle-based API for cross-language compatibility
  • Complete FFI Interface: Matches existing c/ffi.h specification

    • UInt64UnitedMemoryLinks_New/Drop - Instance management
    • UInt64UnitedMemoryLinks_Create/Count/Update/Delete - CRUD operations
    • GetLibraryVersion - Version information
    • All exported symbols verified in generated native library
  • Cross-Platform Native Compilation:

    • Linux: Platform.Data.Doublets.NativeLibrary.so (2.7MB)
    • Windows: Platform.Data.Doublets.NativeLibrary.dll
    • macOS: Platform.Data.Doublets.NativeLibrary.dylib
  • Build Infrastructure:

    • build-native-library.sh - Multi-platform build script
    • test-native-build.sh - Build verification script
    • Updated solution file with new project
  • Documentation & Examples:

    • Comprehensive README with usage instructions
    • C example program demonstrating FFI usage
    • Makefile for building and testing C integration

πŸ”§ Technical Details

NativeAOT vs CoreRT Benefits:

  • Uses modern .NET 8 NativeAOT instead of deprecated CoreRT
  • Better performance with latest AOT optimizations
  • Self-contained deployment (no .NET runtime dependency)
  • Smaller footprint compared to managed deployment
  • Full compatibility with existing FFI consumers

Architecture:

  • Handle-based object management (avoids direct memory management across FFI)
  • Thread-safe operations with proper locking
  • Graceful error handling (returns 0/null on failure)
  • Memory-efficient native compilation

πŸ§ͺ Verification

βœ… Build Success: Native compilation completes without errors
βœ… Symbol Export: All required C functions properly exported
βœ… File Generation: 2.7MB native shared library created
βœ… FFI Compatibility: Matches existing ffi.h interface signatures
βœ… Cross-Platform: Supports Linux, Windows, and macOS targets

πŸ“ Files Added

csharp/Platform.Data.Doublets.NativeLibrary/
β”œβ”€β”€ Platform.Data.Doublets.NativeLibrary.csproj  # NativeAOT project config
β”œβ”€β”€ DoubletsNativeLibrary.cs                      # FFI implementation  
└── README.md                                     # Documentation

csharp/
β”œβ”€β”€ build-native-library.sh                      # Build script
└── test-native-build.sh                         # Test script

examples/c-native-library-test/
β”œβ”€β”€ test.c                                        # C usage example
β”œβ”€β”€ Makefile                                      # Build configuration  
└── README.md                                     # Example documentation

🎯 Closes

Fixes #40

This provides the modern NativeAOT solution requested in the issue, offering better performance and deployment characteristics than the original CoreRT approach.


πŸ€– Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #40
@konard konard self-assigned this Sep 14, 2025
- Create Platform.Data.Doublets.NativeLibrary project with NativeAOT support
- Implement C-style FFI exports matching existing ffi.h interface:
  * UInt64UnitedMemoryLinks_New/Drop for instance management
  * UInt64UnitedMemoryLinks_Create/Count/Update/Delete for operations
  * GetLibraryVersion for version info
- Add build scripts for cross-platform native compilation
- Include comprehensive documentation and C usage example
- Successfully generates 2.7MB native shared library (.so) with all symbols exported
- Compatible with existing FFI interface, provides modern NativeAOT alternative to CoreRT

πŸ€– Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] Try to create a native library version with CoreRT. Implement native library version using NativeAOT Sep 14, 2025
@konard konard marked this pull request as ready for review September 14, 2025 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Try to create a native library version with CoreRT.

2 participants