Open PathogenDavid opened 3 years ago
Note: Make sure to update the documentation for KludgeUnknownClangTypesIntoBuiltinTypesTransformation
when this is completed.
Another quirk revealed by this issue: If more than one function fails to emit a type it can break disambiguation by operator overloading. IE:
class MyClass {}; // <-- Remove this declaration with a transform
void Write(int* x);
void Write(MyClass* x);
will become:
void Write(int* x);
void Write(/* Failed to emit TranslatedParameter x: Failed to resolve `Ref resolved by MyClass` during emit time. `*/ int* x);
Which cannot build.
Honestly we should instead just fail these sorts of methods during the verification stage.
Edit: We actually need to do this after the broken declaration extractor runs because it can break references. (It'd actually probably have to be a persistent transformation.)
Honestly we should instead just fail these sorts of methods during the verification stage.
While we should definitely fail these methods during verification, I think it could be valuable to have the ability to last-minute remove a failed declaration.
We already buffer the contents of the file with a StringBuilder
inside CodeWriter
, we could pretty easily use StringBuilder.Insert
or StringBuilder.Remove
to either #if-disable/remove broken code instead of straining ourselves to make it valid.
Right now if Biohazrd fails to emit a type, it will emit it as int in order to make sure the C# code still compiles:
This is great during generator development because it means you can test unaffected portions of the library without having to resolve these issues.
Unfortunately it also becomes non-obvious that affected members are broken.
In this scenario, we should emit a special type to signify that this member is broken. (We cannot realistically go back and mark the member as obsolete because this is last-chance error handling that occurs while the file is being written. Ideally we might do that for certain cases, but it'd be part of the verification stage.)