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

Method sig_string

crates/csharp/src/interface.rs:1550–1587  ·  view source on GitHub ↗
(&mut self, func: &Function, qualifier: bool)

Source from the content-addressed store, hash-verified

1548 }
1549
1550 fn sig_string(&mut self, func: &Function, qualifier: bool) -> String {
1551 let result_type = self.func_return_type(&func, qualifier);
1552
1553 let params = func
1554 .params
1555 .iter()
1556 .skip(if let FunctionKind::Method(_) = &func.kind {
1557 1
1558 } else {
1559 0
1560 })
1561 .map(|Param { name, ty, .. }| {
1562 let ty = self.type_name_with_qualifier(ty, qualifier);
1563 let name = name.to_csharp_ident();
1564 format!("{ty} {name}")
1565 })
1566 .collect::<Vec<_>>()
1567 .join(", ");
1568
1569 let (camel_name, modifiers) = match &func.kind {
1570 FunctionKind::Freestanding
1571 | FunctionKind::AsyncFreestanding
1572 | FunctionKind::Static(_)
1573 | FunctionKind::AsyncStatic(_) => (func.item_name().to_upper_camel_case(), "static"),
1574
1575 FunctionKind::Method(_) | FunctionKind::AsyncMethod(_) => {
1576 (func.item_name().to_upper_camel_case(), "")
1577 }
1578 FunctionKind::Constructor(id) => (
1579 self.csharp_gen.all_resources[id].name.to_upper_camel_case(),
1580 "",
1581 ),
1582 };
1583
1584 let access = self.csharp_gen.access_modifier();
1585
1586 format!("{access} {modifiers} {result_type} {camel_name}({params})")
1587 }
1588
1589 pub(crate) fn add_future(
1590 &mut self,

Callers 1

exportMethod · 0.45

Calls 7

func_return_typeMethod · 0.80
joinMethod · 0.80
mapMethod · 0.80
to_csharp_identMethod · 0.80
access_modifierMethod · 0.80
iterMethod · 0.45

Tested by

no test coverage detected