Skip to main content

CSharp

Trait CSharp 

Source
pub trait CSharp {
    // Required methods
    fn csharp_name(cfg: &Config) -> String;
    fn csharp_definition(cfg: &Config) -> String;
    fn dependencies(cfg: &Config) -> Vec<String>;

    // Provided method
    fn csharp_fields(_cfg: &Config) -> Vec<CSharpFieldInfo> { ... }
}
Expand description

Generates a C# type definition as a string.

Implementors produce a complete .cs file content including using directives, namespace declaration, and type definition.

Required Methods§

Source

fn csharp_name(cfg: &Config) -> String

Returns the C# type name (e.g., "int", "MyStruct").

Source

fn csharp_definition(cfg: &Config) -> String

Returns the complete .cs file content for this type, or empty for primitives / generics.

Source

fn dependencies(cfg: &Config) -> Vec<String>

Returns C# type names this type depends on (for transitive export).

Provided Methods§

Source

fn csharp_fields(_cfg: &Config) -> Vec<CSharpFieldInfo>

Returns metadata about this type’s fields (used by #[serde(flatten)]).

Only meaningful for struct types. Primitives, generics, and enums return an empty vec (the default implementation).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl CSharp for bool

Source§

impl CSharp for f32

Source§

impl CSharp for f64

Source§

impl CSharp for i8

Source§

impl CSharp for i16

Source§

impl CSharp for i32

Source§

impl CSharp for i64

Source§

impl CSharp for i128

Source§

impl CSharp for u8

Source§

impl CSharp for u16

Source§

impl CSharp for u32

Source§

impl CSharp for u64

Source§

impl CSharp for u128

Source§

impl CSharp for String

Source§

impl<K: CSharp, V: CSharp, S: BuildHasher> CSharp for HashMap<K, V, S>

Source§

impl<T: CSharp> CSharp for Option<T>

Returns the inner type name without a nullable suffix.

Nullability (?) is handled by the derive macro via the is_optional flag in codegen, not by the trait. Calling <Option<i32>>::csharp_name() returns "int", not "int?".

Source§

impl<T: CSharp> CSharp for Vec<T>

Source§

impl<T: CSharp, S: BuildHasher> CSharp for HashSet<T, S>

Implementors§