Biohazrd icon indicating copy to clipboard operation
Biohazrd copied to clipboard

Create infrastructure for emitting private helper types in CSharpLibraryGenerator

Open PathogenDavid opened this issue 3 years ago • 2 comments

Right now there's no easy way to emit implementation detail-type types inside CShapLibraryGenerator. For constant arrays, we need some helper types for allowing them to be enumerated. Right now we just emit them before the first constant array is emitted, but this would not work if the constant array types were spread throughout multiple files.

We should consider providing some canonical mechanism for adding these sorts of types.

PathogenDavid avatar Sep 25 '20 02:09 PathogenDavid

I gave this some more thought while implementing the fix for https://github.com/InfectedLibraries/Biohazrd/issues/146

I think it might be valuable for declarations to be marked for lazy emit. Essentially the declarations won't be written out unless something references them. This would be good for these sorts of infrastructure types as well as things like NativeBool.

We likely want to add some infrastructure for detecting which lazy declarations were emitted so that we can only emit diagnostics relating to these declarations if they were actually emitted. This would be useful in the InfectedWin32 use-case where we only emit declarations filtered by an allowlist and their dependencies.

Although it might be just as easy to have this be a transformation that runs just before output generation.

PathogenDavid avatar Feb 27 '21 10:02 PathogenDavid

TranslatedUndefinedRecord is another good candidate for this. It's usually referenced to start with, but sometimes all references to them are removed by transformations.

PathogenDavid avatar Feb 27 '21 18:02 PathogenDavid