@@ -2,16 +2,12 @@ use crate::csharp_ident::ToCSharpIdent;
22use crate :: function:: ResourceInfo ;
33use crate :: interface:: { InterfaceFragment , InterfaceGenerator , InterfaceTypeAndFragments } ;
44use crate :: { CSharpRuntime , Opts } ;
5- use heck:: { ToSnakeCase , ToUpperCamelCase } ;
5+ use heck:: ToUpperCamelCase ;
66use indexmap:: IndexMap ;
77use std:: collections:: { HashMap , HashSet } ;
88use std:: fmt:: Write ;
99use std:: ops:: Deref ;
1010use std:: { iter, mem} ;
11- use wasm_encoder:: {
12- CodeSection , CustomSection , Function as WasmFunction , FunctionSection , LinkingSection , Module ,
13- SymbolTable , TypeSection ,
14- } ;
1511use wit_bindgen_core:: { Direction , Files , InterfaceGenerator as _, Types , WorldGenerator , uwrite} ;
1612use wit_component:: WitPrinter ;
1713use wit_parser:: abi:: WasmType ;
@@ -861,43 +857,6 @@ impl WorldGenerator for CSharp {
861857 & format ! ( "{world_namespace}_component_type.wit" ) ,
862858 String :: from ( printer. output ) . as_bytes ( ) ,
863859 ) ;
864- files. push (
865- & format ! ( "{world_namespace}_component_type.o" ) ,
866- component_type_object (
867- & resolve,
868- world,
869- & resolve. worlds [ world] . name ,
870- self . opts . string_encoding ,
871- ) ?
872- . as_slice ( ) ,
873- ) ;
874- let linking_symbol = format ! (
875- "__component_type_object_force_link_{}" ,
876- resolve. worlds[ world] . name. to_snake_case( )
877- ) ;
878- files. push (
879- & format ! ( "{world_namespace}_component_type_force_link.cs" ) ,
880- indent ( & format ! (
881- r#"
882- #if WIT_BINDGEN_COMPONENT_TYPE_OBJECT
883- namespace {world_namespace};
884-
885- internal static partial class ComponentTypeObjectForceLink
886- {{
887- [global::System.Runtime.InteropServices.DllImport("__Internal", EntryPoint = "{linking_symbol}")]
888- private static extern void ForceLink();
889-
890- [global::System.Runtime.CompilerServices.ModuleInitializer]
891- internal static void Initialize()
892- {{
893- ForceLink();
894- }}
895- }}
896- #endif
897- "#
898- ) )
899- . as_bytes ( ) ,
900- ) ;
901860 }
902861
903862 // TODO: remove when we switch to dotnet 9
@@ -1158,58 +1117,6 @@ fn by_resource<'a>(
11581117 by_resource
11591118}
11601119
1161- fn component_type_object (
1162- resolve : & Resolve ,
1163- world : WorldId ,
1164- world_name : & str ,
1165- encoding : wit_component:: StringEncoding ,
1166- ) -> anyhow:: Result < Vec < u8 > > {
1167- let mut module = Module :: new ( ) ;
1168-
1169- let mut types = TypeSection :: new ( ) ;
1170- types. ty ( ) . function ( [ ] , [ ] ) ;
1171- module. section ( & types) ;
1172-
1173- let mut funcs = FunctionSection :: new ( ) ;
1174- funcs. function ( 0 ) ;
1175- module. section ( & funcs) ;
1176-
1177- let mut code = CodeSection :: new ( ) ;
1178- let mut func = WasmFunction :: new ( [ ] ) ;
1179- func. instruction ( & wasm_encoder:: Instruction :: End ) ;
1180- code. function ( & func) ;
1181- module. section ( & code) ;
1182-
1183- let mut producers = wasm_metadata:: Producers :: empty ( ) ;
1184- producers. add (
1185- "processed-by" ,
1186- env ! ( "CARGO_PKG_NAME" ) ,
1187- env ! ( "CARGO_PKG_VERSION" ) ,
1188- ) ;
1189- let data = wit_component:: metadata:: encode ( resolve, world, encoding, Some ( & producers) ) ?;
1190- let section_name = format ! ( "component-type:{world_name}" ) ;
1191-
1192- module. section ( & CustomSection {
1193- name : std:: borrow:: Cow :: Borrowed ( & section_name) ,
1194- data : std:: borrow:: Cow :: Borrowed ( data. as_slice ( ) ) ,
1195- } ) ;
1196-
1197- let mut linking = LinkingSection :: new ( ) ;
1198- let mut symbols = SymbolTable :: new ( ) ;
1199- symbols. function (
1200- 0 ,
1201- 0 ,
1202- Some ( & format ! (
1203- "__component_type_object_force_link_{}" ,
1204- world_name. to_snake_case( )
1205- ) ) ,
1206- ) ;
1207- linking. symbol_table ( & symbols) ;
1208- module. section ( & linking) ;
1209-
1210- Ok ( module. finish ( ) )
1211- }
1212-
12131120#[ cfg( test) ]
12141121mod tests {
12151122 use super :: * ;
0 commit comments