A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
fix(sim): CheckNulls walks properties in ordinal order (R3)
eyalgolan50d5b7425587
diff --git a/sim/Statecraft.Sim.Tests/ValidationTests.cs b/sim/Statecraft.Sim.Tests/ValidationTests.csindex 6aad820b3..cee722977 100644--- a/sim/Statecraft.Sim.Tests/ValidationTests.cs+++ b/sim/Statecraft.Sim.Tests/ValidationTests.cs@@ -63,6 +63,16 @@ status: draftAssert.EndsWith(message, ex.Message);}+ // R3: with two null lists, the ordinally-first property is reported on every runtime.+ [Fact]+ public void FirstNullFieldReportedIsOrdinallyFirst()+ {+ var two = Event.Replace("tags: [economy]", "tags:").Replace(+ "options:\n - id: ration\n text: Ration water\n historical: true\n effects:\n - target: food_supply\n delta: 0.1\n - id: wait\n text: Wait for rain\n", "options:\n");+ var ex = Assert.Throws<ContentException>(() => ContentLoader.Load(Fixture.Write(events: new Dictionary<string, string> { ["drought.yaml"] = two })));+ Assert.Equal("events[drought].options", ex.Field);+ }+// I2: enum-like fields.[Theory][InlineData("events/drought.yaml", "anchor: soft", "anchor: hrad", "events[drought].anchor")]diff --git a/sim/Statecraft.Sim/ContentLoader.cs b/sim/Statecraft.Sim/ContentLoader.csindex d4df407f3..4714ff331 100644--- a/sim/Statecraft.Sim/ContentLoader.cs+++ b/sim/Statecraft.Sim/ContentLoader.cs@@ -53,7 +53,7 @@ namespace Statecraft.Sim/// objects, naming list entries by id when they have one, else by index.</summary>static void CheckNulls(string file, string path, object o){- foreach (var p in o.GetType().GetProperties())+ foreach (var p in o.GetType().GetProperties().OrderBy(x => x.Name, StringComparer.Ordinal)){if (p.GetCustomAttribute<YamlIgnoreAttribute>() != null) continue;var key = (path == "" ? "" : path + ".") + UnderscoredNamingConvention.Instance.Apply(p.Name);