-
Notifications
You must be signed in to change notification settings - Fork 252
Closed
Labels
gen-c#Related to the C# code generatorRelated to the C# code generator
Description
Hello. I've used https://github.com/bytecodealliance/componentize-dotnet for the first time today. I ended up incredibly disappointed.
The main problem is a generated file containing some Result-related definitions. In the code, two ArgumentExceptions are thrown. There is no reference to the System namespace, such that compiling the library results in error CS0246: The type or namespace name 'ArgumentException' could not be found.
I have multiple other things I would like to address and discuss. Please let me know if I should take this somewhere else.
- Naming.
- The generated code contains namespaces with parts which are all lowercase. This is unacceptable in C# and actually results in errors in all of my codebases.
- The generated namespaces use the target world's name (
world foo->namespace FooWorld). This means it does not use the containing library's root namespace. This, along with generatingFooWorld.wit.imports.sample.pkg, takes a lot of control out of the user's hands. I do not want the code to be generated in these namespaces.
- Types and declarations.
- In simple examples,
Result<TOk, TErr>andNone(as well asIFooWorldandFooWorld) are not used at all. Why are these generated in those cases? - Why is
Result<TOk, TErr>.Tagsgenerated? The constants (if required at all) can be declared at the class level inResult<TOk, TErr>. - Why are these all declared as
public? I do not want these types to be part of my library. A consumer of my library should never know about internal implementation details. Can I configure this?
I may even want to wrap the generated imports and exports further. Everything being public is a nuisance for this purpose.
- In simple examples,
DllImportmodule and entry point name.- My host app does not export functions in
sample:pkg/foo, but instead inenv. The generated code always uses[DllImport("sample:pkg/foo", ...), ...]. Can I configure this? - My host app does not export functions as
kebab-case, butsnake_case. The generated code always useskebab-case. Can I configure this?
- My host app does not export functions in
- This should be a source generator.
- The fact that this is a separate software from
componentize-dotnetis a huge problem for this point. An incremental source generator using additional files provided by the user would be much more convenient to use. The code would be generated while the user types, not upon executing abuild. This would require the bindings generation to be done completely in C#, but is a lot more pleasant to use.
- The fact that this is a separate software from
cyraid
Metadata
Metadata
Assignees
Labels
gen-c#Related to the C# code generatorRelated to the C# code generator