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

Function interface_name

crates/csharp/src/world_generator.rs:1013–1071  ·  view source on GitHub ↗
(
    csharp: &mut CSharp,
    resolve: &Resolve,
    name: &WorldKey,
    direction: Direction,
)

Source from the content-addressed store, hash-verified

1011}
1012
1013fn interface_name(
1014 csharp: &mut CSharp,
1015 resolve: &Resolve,
1016 name: &WorldKey,
1017 direction: Direction,
1018) -> String {
1019 let pkg = match name {
1020 WorldKey::Name(_) => None,
1021 WorldKey::Interface(id) => {
1022 let pkg = resolve.interfaces[*id].package.unwrap();
1023 Some(resolve.packages[pkg].name.clone())
1024 }
1025 };
1026
1027 let name = format!(
1028 "{}{}",
1029 match name {
1030 WorldKey::Name(name) => name.to_upper_camel_case(),
1031 WorldKey::Interface(id) => resolve.interfaces[*id]
1032 .name
1033 .as_ref()
1034 .unwrap()
1035 .to_upper_camel_case(),
1036 },
1037 match direction {
1038 Direction::Import => "Imports",
1039 Direction::Export => "Exports",
1040 }
1041 );
1042
1043 let namespace = match &pkg {
1044 Some(name) => {
1045 let mut ns = format!(
1046 "{}.{}.",
1047 name.namespace.to_csharp_ident(),
1048 name.name.to_csharp_ident()
1049 );
1050
1051 if let Some(version) = &name.version {
1052 let v = version.to_string().replace(['.', '-', '+'], "_");
1053 ns = format!("{}v{}.", ns, &v);
1054 }
1055 ns
1056 }
1057 None => String::new(),
1058 };
1059
1060 let world_namespace = &csharp.qualifier();
1061
1062 format!(
1063 "{}wit.{}.{}I{name}",
1064 world_namespace,
1065 match direction {
1066 Direction::Import => "Imports",
1067 Direction::Export => "Exports",
1068 },
1069 namespace
1070 )

Callers 3

import_interfaceMethod · 0.85
export_interfaceMethod · 0.85
import_interfaceMethod · 0.85

Calls 3

newFunction · 0.85
to_stringMethod · 0.45
qualifierMethod · 0.45

Tested by

no test coverage detected