Skip to content

Commit 5d9964c

Browse files
authored
make imported resource THandle struct and ctor public (#1017)
Originally, I made these `internal` rather than `public` since they aren't meant to be used in application code. However, that prevents an important use case: splitting the bindings across assemblies. In particular, when targetting a world that includes exports, it's useful to put the generated types and imports in a reusable library, but we can't put the exports in that library since the application code should be providing the entry points. This is analogous to how a CLI library might provide utilities for e.g. parsing command line options, but still leave it to the application to provide a `static int Main` function. In the case of a world that includes one or more exports, we'll want to put the generated code for those exports in the application assembly and put everything else in the library. However, the export code may need to be able to marshal raw resource handles into the appropriate object wrapper for that resource type, and that requires access to the `THandle` struct and corresponding constructor for that class. Signed-off-by: Joel Dice <[email protected]>
1 parent 9fa2861 commit 5d9964c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

crates/csharp/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,9 +1482,9 @@ impl InterfaceGenerator<'_> {
14821482
{access} class {upper_camel}: IDisposable {{
14831483
internal int Handle {{ get; set; }}
14841484
1485-
internal readonly record struct THandle(int Handle);
1485+
{access} readonly record struct THandle(int Handle);
14861486
1487-
internal {upper_camel}(THandle handle) {{
1487+
{access} {upper_camel}(THandle handle) {{
14881488
Handle = handle.Handle;
14891489
}}
14901490

0 commit comments

Comments
 (0)