bottlenoselabs / c2cs

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

Using custom code makes verification of code compile always fail #115

Closed lithiumtoast closed 1 year ago

lithiumtoast commented 2 years ago

Discovered when using Sokol. I have a custom Rgba32F type for sg_color. C2CS complains that it can't find this type when verifying the generated code compiles.

2022-22-10 22:04:09 fail: C2CS.WriteCodeCSharp.WriteCodeCSharpUseCase[0] - CSharpCompileDiagnostic - C# code compilation diagnostic: /Users/lstranks/Programming/bottlenoselabs/sokol-cs/src/cs/production/Sokol/Sokol.cs (1669,20): error CS0246: The type or namespace name 'Rgba32F' could not be found (are you missing a using directive or an assembly reference?).
lithiumtoast commented 2 years ago

Workaround for now is to use the following in for your IWriterCSharpCode implementation:

options.IsEnabledVerifyCSharpCodeCompiles = false;
lithiumtoast commented 1 year ago

This seems to be resolved with adding header/footer code regions and refactoring the code for checking if the code compiles to a common functionality across production and test code.