bottlenoselabs / c2cs

Generate C# bindings from a C header.
MIT License
245 stars 18 forks source link

Add option to declare types outside of class #153

Open shayded-exe opened 11 months ago

shayded-exe commented 11 months ago

I would like to be able to have structs declared directly in the containing namespace, instead of wrapped in the interop class.

lithiumtoast commented 11 months ago

Hey @shayded-exe,

The syntax nodes get "added" to the container syntax node here: https://github.com/bottlenoselabs/c2cs/blob/main/src/cs/production/C2CS.Tool/Features/WriteCodeCSharp/Domain/CodeGenerator/CSharpCodeGenerator.cs#L260.

Changing it so it uses the namespace syntax node directly would be easy enough; I would suggest having it as an option from the config to use namespace syntax node or class syntax node.