SpryFox / DarkConfig

DarkConfig is a configuration library for games which supports fast and expressive iteration
Other
150 stars 19 forks source link

Add a way to retain source file mapping information that can be used post-reification #29

Closed grahamboree closed 2 years ago

grahamboree commented 2 years ago

It's often useful to have a data verification step that checks the config values supplied by a designer. This might check that values are within a certain range, or are cross-referenced in another place. e.g. a "texture" field on a game object description might verified by checking for a matching texture file in the project.

Unfortunately, when this verification happens, we don't have any source file mapping for object fields. This means verification can't generate errors that contain the source of the error, so it's difficult to track down and fix issues. The ideal error message syntax would be something like

verification error: cannot find texture named 'myTexture.png'
file: myGameObject.yaml
line: 12

This is a feature that's super useful in development and isn't useful in production, so incurring up to a moderate performance overhead for this is likely worth the tradeoff...provided there's a way to completely disable it in production builds.

Proposed solutions:

francoisvn commented 2 years ago

Done this downstream with a new attribute ConfigSourceInformation that will auto-populate a string field/property with this info. This can be compiled out with #if so it's not in production builds. Will upstream this soon with a PR :)