@@ -471,9 +471,9 @@ impl WorldGenerator for CSharp {
471
471
{{
472
472
get
473
473
{{
474
- if (Tag == OK)
474
+ if (Tag == OK)
475
475
return (Ok)value;
476
- else
476
+ else
477
477
throw new ArgumentException("expected OK, got " + Tag);
478
478
}}
479
479
}}
@@ -503,23 +503,23 @@ impl WorldGenerator for CSharp {
503
503
504
504
{access} class Option<T> {{
505
505
private static Option<T> none = new ();
506
-
506
+
507
507
private Option()
508
508
{{
509
509
HasValue = false;
510
510
}}
511
-
511
+
512
512
{access} Option(T v)
513
513
{{
514
514
HasValue = true;
515
515
Value = v;
516
516
}}
517
-
517
+
518
518
{access} static Option<T> None => none;
519
-
519
+
520
520
[MemberNotNullWhen(true, nameof(Value))]
521
521
{access} bool HasValue {{ get; }}
522
-
522
+
523
523
{access} T? Value {{ get; }}
524
524
}}
525
525
"# ,
@@ -753,26 +753,27 @@ impl WorldGenerator for CSharp {
753
753
// intended to be used non-interactively at link time, the
754
754
// linker will have no additional information to resolve such
755
755
// ambiguity.
756
- let ( resolve, _ ) =
756
+ let ( resolve, world ) =
757
757
wit_parser:: decoding:: decode_world ( & wit_component:: metadata:: encode (
758
758
& resolve,
759
759
id,
760
760
self . opts . string_encoding ,
761
761
None ,
762
762
) ?) ?;
763
+ let pkg = resolve. worlds [ world] . package . unwrap ( ) ;
763
764
764
765
files. push (
765
766
& format ! ( "{world_namespace}_component_type.wit" ) ,
766
767
WitPrinter :: default ( )
767
768
. emit_docs ( false )
768
769
. print (
769
770
& resolve,
771
+ pkg,
770
772
& resolve
771
773
. packages
772
774
. iter ( )
773
- . map ( |( id, _) | id )
775
+ . filter_map ( |( id, _) | if id == pkg { None } else { Some ( id ) } )
774
776
. collect :: < Vec < _ > > ( ) ,
775
- false ,
776
777
) ?
777
778
. as_bytes ( ) ,
778
779
) ;
@@ -1494,7 +1495,7 @@ impl InterfaceGenerator<'_> {
1494
1495
1495
1496
[DllImport("{module_name}", EntryPoint = "[resource-drop]{name}"), WasmImportLinkage]
1496
1497
private static extern void wasmImportResourceDrop(int p0);
1497
-
1498
+
1498
1499
protected virtual void Dispose(bool disposing) {{
1499
1500
if (Handle != 0) {{
1500
1501
wasmImportResourceDrop(Handle);
@@ -1564,7 +1565,7 @@ impl InterfaceGenerator<'_> {
1564
1565
1565
1566
[DllImport("{module_name}", EntryPoint = "[resource-new]{name}"), WasmImportLinkage]
1566
1567
internal static extern int wasmImportResourceNew(int p0);
1567
-
1568
+
1568
1569
[DllImport("{module_name}", EntryPoint = "[resource-rep]{name}"), WasmImportLinkage]
1569
1570
internal static extern int wasmImportResourceRep(int p0);
1570
1571
}}
@@ -1844,15 +1845,15 @@ impl<'a> wit_bindgen_core::InterfaceGenerator<'a> for InterfaceGenerator<'a> {
1844
1845
let tag = case. name . to_shouty_snake_case ( ) ;
1845
1846
let ty = self . type_name ( ty) ;
1846
1847
format ! (
1847
- r#"{access} {ty} As{case_name}
1848
- {{
1849
- get
1848
+ r#"{access} {ty} As{case_name}
1849
+ {{
1850
+ get
1850
1851
{{
1851
- if (Tag == {tag})
1852
+ if (Tag == {tag})
1852
1853
return ({ty})value!;
1853
- else
1854
+ else
1854
1855
throw new ArgumentException("expected {tag}, got " + Tag);
1855
- }}
1856
+ }}
1856
1857
}}
1857
1858
"#
1858
1859
)
@@ -2584,8 +2585,8 @@ impl Bindgen for FunctionBindgen<'_, '_> {
2584
2585
uwrite ! (
2585
2586
self . src,
2586
2587
"
2587
- var {array} = new {ty}[{length}];
2588
- new Span<{ty}>((void*)({address}), {length}).CopyTo(new Span<{ty}>({array}));
2588
+ var {array} = new {ty}[{length}];
2589
+ new Span<{ty}>((void*)({address}), {length}).CopyTo(new Span<{ty}>({array}));
2589
2590
"
2590
2591
) ;
2591
2592
0 commit comments