kontent-ai / model-generator-net

Kontent.ai .NET model generator.
https://www.nuget.org/packages/Kontent.Ai.ModelGenerator
MIT License
17 stars 19 forks source link

Deterministic output of generated models #99

Closed xantari closed 4 years ago

xantari commented 4 years ago

Motivation

When we re-generate models the generator seems to randomly order the properties in the model.

So even if the model had no changes, when you do a diff on one generated model compared to the previous they are different, even though they are the same.

See here for an example of a model that was re-generated using the beta-2 command line kontent generator.

During code reviews people will ask questions on why this was done. It also causes unnecessary noise during code reviews.

image

Proposed solution

Perhaps just sort all properties alphabetically is an easy fix for this issue. That way everything gets generated the same way all the time.

petrsvihlik commented 4 years ago

Good point @xantari, ordering alphabetically will make things easier to compare.

fixed in https://github.com/Kentico/kontent-generators-net/releases/tag/5.0.0-beta5

xantari commented 4 years ago

You guys rock! Thanks so much.