MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / new

Method new

crates/codegen/src/csharp.rs:1340–1371  ·  view source on GitHub ↗
(namespace: &str, extra_usings: &[&str], include_version: bool)

Source from the content-addressed store, hash-verified

1338
1339impl CsharpAutogen {
1340 pub fn new(namespace: &str, extra_usings: &[&str], include_version: bool) -> Self {
1341 let mut output = CodeIndenter::new(String::new(), INDENT);
1342
1343 print_auto_generated_file_comment(&mut output);
1344 if include_version {
1345 print_auto_generated_version_comment(&mut output);
1346 }
1347
1348 writeln!(output, "#nullable enable");
1349 writeln!(output);
1350
1351 writeln!(output, "using System;");
1352 // Don't emit `using SpacetimeDB;` if we are going to be nested in the SpacetimeDB namespace.
1353 if namespace
1354 .split('.')
1355 .next()
1356 .expect("split always returns at least one string")
1357 != "SpacetimeDB"
1358 {
1359 writeln!(output, "using SpacetimeDB;");
1360 }
1361 for extra_using in extra_usings {
1362 writeln!(output, "using {extra_using};");
1363 }
1364 writeln!(output);
1365
1366 writeln!(output, "namespace {namespace}");
1367 writeln!(output, "{{");
1368 output.indent(1);
1369
1370 Self { output }
1371 }
1372
1373 pub fn into_inner(mut self) -> String {
1374 self.dedent(1);

Callers

nothing calls this directly

Calls 6

splitMethod · 0.80
newFunction · 0.50
nextMethod · 0.45
indentMethod · 0.45

Tested by

no test coverage detected