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§
Sourcefn csharp_name(cfg: &Config) -> String
fn csharp_name(cfg: &Config) -> String
Returns the C# type name (e.g., "int", "MyStruct").
Sourcefn csharp_definition(cfg: &Config) -> String
fn csharp_definition(cfg: &Config) -> String
Returns the complete .cs file content for this type, or empty for
primitives / generics.
Sourcefn dependencies(cfg: &Config) -> Vec<String>
fn dependencies(cfg: &Config) -> Vec<String>
Returns C# type names this type depends on (for transitive export).
Provided Methods§
Sourcefn csharp_fields(_cfg: &Config) -> Vec<CSharpFieldInfo>
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<T: CSharp> CSharp for Option<T>
Returns the inner type name without a nullable suffix.
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?".