pub struct Config { /* private fields */ }Expand description
Runtime configuration for C# code generation.
Controls namespace, serializer library, C# language version, and export
directory. Construct with Config::default and customize with builder
methods.
§Examples
use csharp_rs::{Config, Serializer, CSharpVersion};
let cfg = Config::default()
.with_serializer(Serializer::Newtonsoft)
.with_target(CSharpVersion::CSharp11);Implementations§
Source§impl Config
impl Config
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Creates a configuration from environment variables.
Reads the following environment variables, falling back to defaults for missing or invalid values:
CSHARP_RS_EXPORT_DIR— output directory (default:"./csharp-bindings")CSHARP_RS_SERIALIZER—"stj"or"newtonsoft"(default:"stj")CSHARP_RS_TARGET—"unity","9","10","11","12"(default:"9")CSHARP_RS_NAMESPACE— C# namespace (default:"Generated")
Sourcepub fn with_namespace(self, ns: &str) -> Self
pub fn with_namespace(self, ns: &str) -> Self
Sets the root namespace. Panics if the value is not a valid C# namespace.
§Panics
Panics if ns fails CSharpNamespace validation.
Sourcepub fn with_validated_namespace(self, ns: CSharpNamespace) -> Self
pub fn with_validated_namespace(self, ns: CSharpNamespace) -> Self
Sets the root namespace from a pre-validated CSharpNamespace.
Sourcepub fn with_serializer(self, serializer: Serializer) -> Self
pub fn with_serializer(self, serializer: Serializer) -> Self
Sets the target serializer library.
Sourcepub fn with_target(self, target: CSharpVersion) -> Self
pub fn with_target(self, target: CSharpVersion) -> Self
Sets the target C# language version.
Sourcepub fn with_export_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn with_export_dir(self, dir: impl Into<PathBuf>) -> Self
Sets the export directory for generated .cs files.
Sourcepub fn serializer(&self) -> Serializer
pub fn serializer(&self) -> Serializer
Returns the configured serializer.
Sourcepub fn target(&self) -> CSharpVersion
pub fn target(&self) -> CSharpVersion
Returns the configured C# target version.
Sourcepub fn export_dir(&self) -> &Path
pub fn export_dir(&self) -> &Path
Returns the configured export directory.