Conversation
- dnne-gen: Add -l flag to select output language (c99 default, rust)
- RustTypeProvider maps .NET types to Rust (i32, f64, *mut c_void, etc.)
- EmitRust generates idiomatic Rust with pub unsafe fn exports,
AtomicPtr lazy init, and #[cfg(target_os)] platform guards
- Language-aware attribute detection via TryGetLanguageTypeAttributeValue
and TryGetLanguageDeclCodeAttributeValue
- Exports with unsupplied value types are skipped in Rust mode
- dnne-analyzers: Add RustTypeAttribute and RustDeclCodeAttribute
source-generated into consuming projects
- platform.rs: Rust equivalent of platform.c (.NET Core only)
- Runtime hosting via nethost/hostfxr
- Thread-safe init with std::sync::Mutex
- Idiomatic Rust public API (FailureType enum, FailureFn, Result returns)
- Cross-platform with cfg modules for Unix and Windows
- UTF-8 string interface with internal wide-string conversion on Windows
- Updated copilot-instructions.md to document Rust support
- Rust.cs: Generate Cargo.toml and build.rs instead of invoking rustc - Propagate .NET assembly version to Cargo.toml - Emit --cfg flags and nethost link directives in build.rs - Copy generated crate to output directory (dnne-rust-crate/) - DNNE.targets: Skip compile/copy steps for Rust language - Fix MapOSPlatformToRustCfg: custom names emit plain cfg flags - Add ImportingProcess.Rust as Cargo project consuming the crate - Add AssemblyVersion property to CreateCompileCommand task
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a Rust output mode to DNNE so managed exports can be consumed as an idiomatic Cargo crate (in addition to existing C99 output), with accompanying MSBuild integration, generator/analyzer updates, and docs/samples.
Changes:
- Introduces a Rust output language path through MSBuild (
DnneLanguage) anddnne-gen(-l rust), including generation/copying of Rust crate files. - Adds Rust-specific customization attributes (
RustDeclCodeAttribute,RustTypeAttribute) and Rust code emission indnne-gen. - Adds a Rust consuming sample project and updates repo documentation and ignore patterns.
Reviewed changes
Copilot reviewed 14 out of 16 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| test/ImportingProcess.Rust/src/main.rs | Adds a Rust sample executable consuming generated DNNE Rust crate exports. |
| test/ImportingProcess.Rust/Cargo.toml | Adds Cargo manifest for the Rust sample with a path dependency on the generated crate. |
| test/ImportingProcess.Rust/Cargo.lock | Locks dependencies for the Rust sample. |
| test/ExportingAssembly/ExportingAssembly.csproj | Adjusts test assembly build flags to support Rust (--cfg ...) vs C99 (override.c). |
| test/DNNE.UnitTests/DNNE.UnitTests.csproj | Changes unit test TFM (now net10.0). |
| src/platform/platform.rs | Adds Rust platform hosting layer (nethost/hostfxr) for generated Rust crates. |
| src/msbuild/DNNE.targets | Adds DnneLanguage, switches generated source extension (.g.c vs .g.rs), and adds Rust crate generation/copy steps. |
| src/msbuild/DNNE.props | Documents/configures DnneLanguage MSBuild property. |
| src/msbuild/DNNE.BuildTasks/Rust.cs | Adds Rust crate file generation (Cargo.toml/build.rs) in build tasks. |
| src/msbuild/DNNE.BuildTasks/CreateCompileCommand.cs | Routes Rust builds to crate generation instead of native compilation; plumbs Language/AssemblyVersion. |
| src/dnne-gen/Program.cs | Adds -l/--language CLI option and passes language to the generator. |
| src/dnne-gen/Generator.cs | Adds Rust emission path (type provider, attribute selection, Rust codegen, cfg mapping). |
| src/dnne-analyzers/AttributesGenerator.cs | Adds analyzer-generated Rust attribute types. |
| readme.md | Documents Rust crate generation/consumption and Rust-specific customization. |
| .gitignore | Ignores Cargo target/ directories. |
| .github/copilot-instructions.md | Adds repo guidance including Rust pipeline documentation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ate file creation
…ion, and enhance Rust crate generation with additional files
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 21 out of 23 changed files in this pull request and generated 9 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jkoritzinsky
approved these changes
Feb 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds first-class Rust output support to DNNE, enabling .NET assemblies to export native methods as idiomatic Rust crates in addition to C99. It updates documentation, extends the code generator and analyzer with Rust-specific attributes, and clarifies platform requirements and usage for Rust consumers.
Rust support and documentation:
readme.md,.github/copilot-instructions.md) describing how to generate and consume Rust crates from .NET assemblies, including build instructions, crate structure, usage examples, and platform-specific notes. [1] [2] [3] [4] [5] [6] [7] [8] [9]Analyzer and attribute enhancements:
RustDeclCodeAttributeandRustTypeAttributein the analyzer-generated attributes, allowing users to provide Rust-specific type mappings and declaration code for export customization.Code generator improvements:
dnne-gen) to accept a-l/--languageoption for selecting the output language (c99orrust), defaulting to C99 for backward compatibility. The generator now passes the language selection throughout the pipeline. [1] [2] [3] [4]Sample and platform requirements:
These changes collectively make DNNE a multi-language export solution, with robust support for both C99 and Rust native interop.
Most important changes:
Rust support and documentation
readme.mdand.github/copilot-instructions.md. [1] [2] [3] [4] [5] [6] [7] [8] [9]Analyzer and attribute enhancements
RustDeclCodeAttributeandRustTypeAttributeto the analyzer-generated source, enabling Rust-specific type and declaration customization for exported methods and parameters.Code generator improvements
dnne-genCLI to accept a-l <language>argument, allowing selection between C99 and Rust output, and propagated this option through the generator pipeline. [1] [2] [3] [4]Sample and platform requirements