fix(build): run the persistence generator against the current data model

The PreBuild targets ran the generator with "--no-build", so it used whatever
assemblies happened to sit in its output folder. When that copy of the data model
was older than a newly added type, the generator regenerated the checked-in
*.Generated.cs files WITHOUT that type and overwrote them in the source tree.

Nothing failed at build time: the C# compile stayed green and docker builds
(-p:ci=true) skip the generator entirely, so they compiled whatever was in the
tree. The damage only surfaced at runtime, when EF validated the model and found
the inherited GameConfiguration.CastleSiegeConfiguration navigation pointing at a
keyless type - the server died on startup with "The entity type
'CastleSiegeConfiguration' requires a primary key to be defined".

Dropping the switch makes the generator build first, so its output always matches
the data model. The regenerated files here are that missing output: the Castle
Siege mappings, and the packet tests for packets whose XML was already committed.

TypedContextModelTests builds the typed context the startup reads its plugin
configurations through - the first one to touch the model - so this class of
breakage fails in seconds without a database.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Acentech Dev
2026-08-04 21:43:39 +03:00
parent 6f7e58ff35
commit af46499279
9 changed files with 273 additions and 4 deletions

View File

@@ -3904,6 +3904,24 @@ public class PacketStructureTests
"Packet length mismatch: declared length does not match calculated size");
}
/// <summary>
/// Tests the packet size calculation for HeykelSavasiTeamSelect.
/// </summary>
[Test]
public void HeykelSavasiTeamSelect_PacketSizeValidation()
{
// Fixed-length packet validation
const int expectedLength = 4;
var actualLength = HeykelSavasiTeamSelectRef.Length;
Assert.That(actualLength, Is.EqualTo(expectedLength),
"Packet length mismatch: declared length does not match calculated size");
// Validate field 'Team' boundary
Assert.That(3 + 1, Is.LessThanOrEqualTo(expectedLength),
"Field 'Team' exceeds packet boundary");
}
/// <summary>
/// Tests the packet size calculation for ChatCommandListRequest.
/// </summary>

View File

@@ -6415,10 +6415,102 @@ public class PacketStructureTests
}
/// <summary>
/// Tests the packet size calculation for ChatCommandInfo.
/// Tests the packet size calculation for HeykelSavasiOpenTeamPanel.
/// </summary>
[Test]
public void ChatCommandInfo_PacketSizeValidation()
public void HeykelSavasiOpenTeamPanel_PacketSizeValidation()
{
// Fixed-length packet validation
const int expectedLength = 5;
var actualLength = HeykelSavasiOpenTeamPanelRef.Length;
Assert.That(actualLength, Is.EqualTo(expectedLength),
"Packet length mismatch: declared length does not match calculated size");
// Validate field 'RedCount' boundary
Assert.That(3 + 1, Is.LessThanOrEqualTo(expectedLength),
"Field 'RedCount' exceeds packet boundary");
// Validate field 'BlueCount' boundary
Assert.That(4 + 1, Is.LessThanOrEqualTo(expectedLength),
"Field 'BlueCount' exceeds packet boundary");
}
/// <summary>
/// Tests the packet size calculation for HeykelSavasiHudState.
/// </summary>
[Test]
public void HeykelSavasiHudState_PacketSizeValidation()
{
// Fixed-length packet validation
const int expectedLength = 11;
var actualLength = HeykelSavasiHudStateRef.Length;
Assert.That(actualLength, Is.EqualTo(expectedLength),
"Packet length mismatch: declared length does not match calculated size");
// Validate field 'Phase' boundary
Assert.That(3 + 1, Is.LessThanOrEqualTo(expectedLength),
"Field 'Phase' exceeds packet boundary");
// Validate field 'MyTeam' boundary
Assert.That(4 + 1, Is.LessThanOrEqualTo(expectedLength),
"Field 'MyTeam' exceeds packet boundary");
// Validate field 'RedCount' boundary
Assert.That(5 + 1, Is.LessThanOrEqualTo(expectedLength),
"Field 'RedCount' exceeds packet boundary");
// Validate field 'BlueCount' boundary
Assert.That(6 + 1, Is.LessThanOrEqualTo(expectedLength),
"Field 'BlueCount' exceeds packet boundary");
// Validate field 'RedProgress' boundary
Assert.That(7 + 1, Is.LessThanOrEqualTo(expectedLength),
"Field 'RedProgress' exceeds packet boundary");
// Validate field 'BlueProgress' boundary
Assert.That(8 + 1, Is.LessThanOrEqualTo(expectedLength),
"Field 'BlueProgress' exceeds packet boundary");
// Validate field 'RemainingSeconds' boundary
Assert.That(9 + 2, Is.LessThanOrEqualTo(expectedLength),
"Field 'RemainingSeconds' exceeds packet boundary");
}
/// <summary>
/// Tests the packet size calculation for HeykelSavasiTeamRoster.
/// </summary>
[Test]
public void HeykelSavasiTeamRoster_PacketSizeValidation()
{
// Basic packet validation
// Validate header type and field boundaries
// Field 'Count' starts at index 3 with size 1
Assert.That(3, Is.GreaterThanOrEqualTo(0),
"Field 'Count' has invalid negative index");
}
/// <summary>
/// Tests the packet size calculation for HeykelSavasiScoreboard.
/// </summary>
[Test]
public void HeykelSavasiScoreboard_PacketSizeValidation()
{
// Basic packet validation
// Validate header type and field boundaries
// Field 'Count' starts at index 3 with size 1
Assert.That(3, Is.GreaterThanOrEqualTo(0),
"Field 'Count' has invalid negative index");
}
/// <summary>
/// Tests the packet size calculation for AvailableChatCommand.
/// </summary>
[Test]
public void AvailableChatCommand_PacketSizeValidation()
{
// Basic packet validation
// Validate header type and field boundaries