COMMUNITY

How to ensure my unused type appears in Context.onGenerate?

This is sort of a simple question, may not be possible, but wanted to triple check just to be sure.

Even with dce disabled, a class/type does not appear in the Context.onGenerate callback unless it’s used somewhere within the program. Is there a way to ensure it appears without explicitly using it or knowing its name/path during macro execution?

Preferably it would be done by modifying the class itself or its metadata. Is there an arbitrary metadata or @:build technique that would allow this?

It’s impossible if it’s not referenced somewhere.
If you don’t want to use it in the code, you can add a compiler argument --macro include('path.to.MyType')
If you’re making a lib, you can add that argument to extraParams.hxml in the root of your lib.

Ahhh, all right, thank you!