MCPcopy Create free account
hub / github.com/bytecodealliance/wit-bindgen / finish

Method finish

crates/csharp/src/world_generator.rs:383–944  ·  view source on GitHub ↗
(&mut self, resolve: &Resolve, id: WorldId, files: &mut Files)

Source from the content-addressed store, hash-verified

381 }
382
383 fn finish(&mut self, resolve: &Resolve, id: WorldId, files: &mut Files) -> anyhow::Result<()> {
384 if !self.import_funcs_called {
385 // Ensure that we emit type declarations for any top-level imported resource types:
386 self.import_funcs(resolve, id, &[], files);
387 }
388
389 let world = &resolve.worlds[id];
390 let world_namespace = self.qualifier();
391 let world_namespace = world_namespace.strip_suffix(".").unwrap();
392 let namespace = world_namespace;
393 let name = world.name.to_upper_camel_case();
394
395 let version = env!("CARGO_PKG_VERSION");
396 let header = format!(
397 "\
398 // Generated by `wit-bindgen` {version}. DO NOT EDIT!
399 // <auto-generated />
400 #nullable enable
401 "
402 );
403 let mut src = String::new();
404 src.push_str(&header);
405
406 let mut producers = wasm_metadata::Producers::empty();
407 producers.add(
408 "processed-by",
409 env!("CARGO_PKG_NAME"),
410 env!("CARGO_PKG_VERSION"),
411 );
412
413 let access = self.access_modifier();
414
415 if self.needs_async_support {
416 uwrite!(
417 src,
418 "
419 using System.Runtime.CompilerServices;
420
421 "
422 );
423 }
424
425 uwrite!(
426 src,
427 "
428 using System;
429 using System.Runtime.InteropServices;
430 using System.Collections.Concurrent;
431 using System.Threading;
432 using System.Threading.Tasks;
433 "
434 );
435 uwrite!(
436 src,
437 "
438 namespace {world_namespace} {{
439
440 "

Callers

nothing calls this directly

Calls 15

newFunction · 0.85
dotnet_aligned_arrayFunction · 0.85
access_modifierMethod · 0.80
joinMethod · 0.80
mapMethod · 0.80
as_strMethod · 0.80
write_world_fragmentsMethod · 0.80
allMethod · 0.80
indentFunction · 0.70
import_funcsMethod · 0.45
qualifierMethod · 0.45
push_strMethod · 0.45

Tested by

no test coverage detected