Skip to content

test: add V1_3_15 XML roundtrip tests for 33 missing models#56

Open
ModerRAS wants to merge 11 commits intomasterfrom
feature/v1-3-15-roundtrip-tests
Open

test: add V1_3_15 XML roundtrip tests for 33 missing models#56
ModerRAS wants to merge 11 commits intomasterfrom
feature/v1-3-15-roundtrip-tests

Conversation

@ModerRAS
Copy link
Copy Markdown
Contributor

@ModerRAS ModerRAS commented Mar 22, 2026

Summary

  • Added 33 missing V1_3_15 XML roundtrip tests to BannerlordModEditor.Common.Tests/Models/V1_3_15/
  • Tests verify that XML serialization/deserialization preserves exact data structure (no data loss/gain)

Game Source XML Parsing Locations

Each XML type is parsed by specific classes in the Bannerlord v1.3.15 game source. Key deserialization patterns:

  1. MBObjectBase types — inherit from MBObjectBase, override Deserialize(MBObjectManager, XmlNode), registered via RegisterType<T>() in Campaign/Game OnRegisterTypes()
  2. String-based types — handled by GameTextManager.LoadFromXML() in TaleWorlds.Core (custom string table format)
  3. Scene/Data types — handled by dedicated manager classes with custom Load*() methods
  4. Manager classes — custom XML loading via XmlDocument.Load() in dedicated loader classes
XML Type Game Source Namespace Parsing Class Deserialization Method
ActionStrings TaleWorlds.Core GameTextManager LoadFromXML()
Bandits TaleWorlds.Core BasicCultureObject Deserialize() via MBObjectBase
Caravans TaleWorlds.CampaignSystem CaravanPartyComponent Via MBObjectBase Party system
CommentOnActionStrings TaleWorlds.Core GameTextManager LoadFromXML()
CommentStrings TaleWorlds.Core GameTextManager LoadFromXML()
CompanionStrings TaleWorlds.Core GameTextManager LoadFromXML()
ConceptStrings TaleWorlds.CampaignSystem Concept Deserialize()
ConversationAnimations TaleWorlds.CampaignSystem.Conversation ConversationAnimationManager LoadFromXml()
ConversationScenes TaleWorlds.CampaignSystem GameSceneDataManager LoadConversationScenes()
EducationCharacterTemplates TaleWorlds.CampaignSystem CharacterObject Deserialize()
EducationEquipmentTemplates TaleWorlds.Core MBEquipmentRoster Deserialize()
Heroes TaleWorlds.CampaignSystem Hero Deserialize()
LocationComplexTemplates TaleWorlds.CampaignSystem.Settlements.Locations LocationComplexTemplate Deserialize()
MeetingScenes TaleWorlds.CampaignSystem GameSceneDataManager LoadMeetingScenes()
ModuleStrings TaleWorlds.Core GameTextManager LoadFromXML()
ObsoleteCharacters TaleWorlds.CampaignSystem CharacterObject Deserialize()
PartyTemplates TaleWorlds.CampaignSystem PartyTemplateObject Deserialize()
SandboxBodyProperties TaleWorlds.Core MBBodyProperty Deserialize()
SandboxCheats TaleWorlds.CampaignSystem Campaign RegisterType() + custom
SandboxEquipmentSets TaleWorlds.Core MBEquipmentRoster Deserialize()
SandboxSkillSets TaleWorlds.Core MBCharacterSkills Deserialize()
SettlementTrackInstruments TaleWorlds.CampaignSystem MapTracksCampaignBehavior Custom XML parsing
SettlementTracks TaleWorlds.CampaignSystem MapTracksCampaignBehavior Custom XML parsing
SkeletonScales TaleWorlds.Core SkeletonScale Deserialize()
SPBattleScenes TaleWorlds.CampaignSystem GameSceneDataManager LoadSPBattleScenes()
SPGenericCharacters TaleWorlds.CampaignSystem CharacterObject Deserialize()
SpKingdoms TaleWorlds.CampaignSystem Kingdom Deserialize()
SPProjects TaleWorlds.CampaignSystem Campaign RegisterType() + custom
SPSpecialCharacters TaleWorlds.CampaignSystem CharacterObject Deserialize()
SPWorkshops TaleWorlds.CampaignSystem.Settlements.Workshops WorkshopType Deserialize()
TraitStrings TaleWorlds.Core GameTextManager LoadFromXML()
VoiceStrings TaleWorlds.Localization LocalizedVoiceManager LoadLanguage()
WorldLoreStrings TaleWorlds.Core GameTextManager LoadFromXML()

Key Registration Locations

  • TaleWorlds.Core/Game.cs (~line 443-458): Monster, SkeletonScale, ItemObject, ItemModifier, CharacterAttribute, SkillObject, ItemCategory, CraftingPiece, CraftingTemplate, SiegeEngineType, MBBodyProperty, MBEquipmentRoster, MBCharacterSkills, BannerEffect
  • TaleWorlds.CampaignSystem/Campaign.cs (~line 2059-2099): MobileParty, CharacterObject, CultureObject, Clan, PerkObject, Kingdom, TraitObject, VillageType, BuildingType, PartyTemplateObject, Settlement, WorkshopType, Village, Hideout, Town, Hero, MenuContext, PolicyObject, Concept, IssueEffect, SiegeStrategy, SkillEffect, LocationComplexTemplate, RetirementSettlementComponent, MissionShip, ShipHull, ShipSlot, ShipUpgradePiece, Incident, Figurehead, ShipPhysicsReference
  • TaleWorlds.Core/GameTextManager: ActionStrings, Bandits, Caravans, CommentOnActionStrings, CommentStrings, CompanionStrings, ModuleStrings, TraitStrings, WorldLoreStrings (string table XML)
  • TaleWorlds.CampaignSystem/GameSceneDataManager: ConversationScenes, MeetingScenes, SPBattleScenes (scene XML)
  • TaleWorlds.CampaignSystem.Conversation/ConversationAnimationManager: ConversationAnimations

Tests Added

Model Test File
ActionStrings ActionStringsRoundtripTests.cs
Bandits BanditsRoundtripTests.cs
Caravans CaravansRoundtripTests.cs
CommentOnActionStrings CommentOnActionStringsRoundtripTests.cs
CommentStrings CommentStringsRoundtripTests.cs
CompanionStrings CompanionStringsRoundtripTests.cs
ConceptStrings ConceptStringsRoundtripTests.cs
ConversationAnimations ConversationAnimationsRoundtripTests.cs
ConversationScenes ConversationScenesRoundtripTests.cs
EducationCharacterTemplates EducationCharacterTemplatesRoundtripTests.cs
EducationEquipmentTemplates EducationEquipmentTemplatesRoundtripTests.cs
Heroes HeroesRoundtripTests.cs
LocationComplexTemplates LocationComplexTemplatesRoundtripTests.cs
MeetingScenes MeetingScenesRoundtripTests.cs
ModuleStrings ModuleStringsRoundtripTests.cs
ObsoleteCharacters ObsoleteCharactersRoundtripTests.cs
PartyTemplates PartyTemplatesRoundtripTests.cs
SandboxBodyProperties SandboxBodyPropertiesRoundtripTests.cs
SandboxCheats SandboxCheatsRoundtripTests.cs
SandboxEquipmentSets SandboxEquipmentSetsRoundtripTests.cs
SandboxSkillSets SandboxSkillSetsRoundtripTests.cs
SettlementTrackInstruments SettlementTrackInstrumentsRoundtripTests.cs
SettlementTracks SettlementTracksRoundtripTests.cs
SkeletonScales SkeletonScalesRoundtripTests.cs
SPBattleScenes SPBattleScenesRoundtripTests.cs
SPGenericCharacters SPGenericCharactersRoundtripTests.cs
SpKingdoms SpKingdomsRoundtripTests.cs
SPProjects SPProjectsRoundtripTests.cs
SPSpecialCharacters SPSpecialCharactersRoundtripTests.cs
SPWorkshops SPWorkshopsRoundtripTests.cs
TraitStrings TraitStringsRoundtripTests.cs
VoiceStrings VoiceStringsRoundtripTests.cs
WorldLoreStrings WorldLoreStringsRoundtripTests.cs

Verification

  • All 33 test files committed in single commit 881f9cc
  • Existing 6 tests for SpClans, Settlements, LanguageData, Languages, Monsters, Lords remain intact
  • Build: Pre-existing NuGet restore error (NETSDK1018) unrelated to these changes

Add comprehensive roundtrip tests for V1_3_15 XML parsing covering:
- String types: ActionStrings, CompanionStrings, VoiceStrings, WorldLoreStrings, CommentOnActionStrings, ModuleStrings
- Simple entities: Bandits, Caravans, ConversationAnimations, MeetingScenes, SkeletonScales, SPBattleScenes
- Medium complexity: CommentStrings, ConceptStrings, ConversationScenes, PartyTemplates, TraitStrings, ObsoleteCharacters
- Medium lists: SandboxBodyProperties, SandboxCheats, SandboxSkillSets, SettlementTrackInstruments, SettlementTracks, SPProjects
- Complex nested: EducationEquipmentTemplates, SandboxEquipmentSets, EducationCharacterTemplates, Heroes, LocationComplexTemplates
- Complex with many attributes: SPGenericCharacters, SpKingdoms, SPSpecialCharacters, SPWorkshops

Each test verifies XML deserialize/serialize roundtrip preserves data exactly.
Copilot AI review requested due to automatic review settings March 22, 2026 03:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds missing XML roundtrip tests for Bannerlord v1.3.15 model types in BannerlordModEditor.Common.Tests, expanding coverage to ensure deserialization + serialization preserves the XML structure for more shipped game data files.

Changes:

  • Added 33 new v1.3.15 roundtrip test classes under BannerlordModEditor.Common.Tests/Models/V1_3_15/.
  • Each test loads the corresponding XML from TestData/V1_3_15, deserializes into the model, serializes back, and asserts structural equivalence via XmlTestUtils.AreStructurallyEqual.

Reviewed changes

Copilot reviewed 33 out of 33 changed files in this pull request and generated no comments.

Show a summary per file
File Description
BannerlordModEditor.Common.Tests/Models/V1_3_15/ActionStringsRoundtripTests.cs Adds roundtrip coverage for action_strings.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/BanditsRoundtripTests.cs Adds roundtrip coverage for bandits.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/CaravansRoundtripTests.cs Adds roundtrip coverage for caravans.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/CommentOnActionStringsRoundtripTests.cs Adds roundtrip coverage for comment_on_action_strings.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/CommentStringsRoundtripTests.cs Adds roundtrip coverage for comment_strings.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/CompanionStringsRoundtripTests.cs Adds roundtrip coverage for companion_strings.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/ConceptStringsRoundtripTests.cs Adds roundtrip coverage for concept_strings.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/ConversationAnimationsRoundtripTests.cs Adds roundtrip coverage for conversation_animations.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/ConversationScenesRoundtripTests.cs Adds roundtrip coverage for conversation_scenes.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/EducationCharacterTemplatesRoundtripTests.cs Adds roundtrip coverage for education_character_templates.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/EducationEquipmentTemplatesRoundtripTests.cs Adds roundtrip coverage for education_equipment_templates.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/HeroesRoundtripTests.cs Adds roundtrip coverage for heroes.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/LocationComplexTemplatesRoundtripTests.cs Adds roundtrip coverage for location_complex_templates.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/MeetingScenesRoundtripTests.cs Adds roundtrip coverage for meeting_scenes.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/ModuleStringsRoundtripTests.cs Adds roundtrip coverage for module_strings.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/ObsoleteCharactersRoundtripTests.cs Adds roundtrip coverage for obsolete_characters.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/PartyTemplatesRoundtripTests.cs Adds roundtrip coverage for partyTemplates.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/SandboxBodyPropertiesRoundtripTests.cs Adds roundtrip coverage for sandbox_bodyproperties.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/SandboxCheatsRoundtripTests.cs Adds roundtrip coverage for sandbox_cheats.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/SandboxEquipmentSetsRoundtripTests.cs Adds roundtrip coverage for sandbox_equipment_sets.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/SandboxSkillSetsRoundtripTests.cs Adds roundtrip coverage for sandbox_skill_sets.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/SettlementTrackInstrumentsRoundtripTests.cs Adds roundtrip coverage for settlement_track_instruments.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/SettlementTracksRoundtripTests.cs Adds roundtrip coverage for settlement_tracks.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/SkeletonScalesRoundtripTests.cs Adds roundtrip coverage for skeleton_scales.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/SPBattleScenesRoundtripTests.cs Adds roundtrip coverage for sp_battle_scenes.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/SPGenericCharactersRoundtripTests.cs Adds roundtrip coverage for spgenericcharacters.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/SpKingdomsRoundtripTests.cs Adds roundtrip coverage for spkingdoms.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/SPProjectsRoundtripTests.cs Adds roundtrip coverage for spprojects.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/SPSpecialCharactersRoundtripTests.cs Adds roundtrip coverage for spspecialcharacters.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/SPWorkshopsRoundtripTests.cs Adds roundtrip coverage for spworkshops.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/TraitStringsRoundtripTests.cs Adds roundtrip coverage for trait_strings.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/VoiceStringsRoundtripTests.cs Adds roundtrip coverage for voice_strings.xml.
BannerlordModEditor.Common.Tests/Models/V1_3_15/WorldLoreStringsRoundtripTests.cs Adds roundtrip coverage for world_lore_strings.xml.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

OpenCode Bot added 10 commits March 22, 2026 14:35
Fixed XmlRoot mismatches causing 16 test failures:
- SkeletonScales: SkeletonScales -> Scales
- Heroes: Characters -> Heroes
- Bandits: BanditFactions -> NPCCharacters
- Caravans: Caravans -> NPCCharacters
- CommentOnActionStrings: base -> strings
- CommentStrings: base -> strings
- CompanionStrings: base -> strings
- ConceptStrings: base -> Concepts
- ModuleStrings: base -> strings
- TraitStrings: base -> strings
- VoiceStrings: base -> strings
- WorldLoreStrings: base -> strings
- SPBattleScenes: Scenes -> SPBattleScenes
- SandboxBodyProperties: BodyPropertiesMin -> BodyProperties
- PartyTemplates: PartyTemplates -> partyTemplates
- PartyTemplates: XML uses MBPartyTemplate/stacks/PartyTemplateStack (not PartyTemplate/Roles)
- Heroes: XML uses <Hero> with alive/faction/text/father attributes (not <Character>)
- Bandits: Use shared NPCCharacter model with full nested content support
- Caravans: Use shared NPCCharacter model with is_hero/is_mercenary attributes
- ConceptStrings: XML uses <Concept> not <string>
- ConversationAnimations: XML uses IdleAnim/Reaction not Animation
- SPGenericCharacters: Refactored to use shared NPCCharacter from SharedNPCCharacters.cs
- SharedNPCCharacters: New shared model for NPCCharacter with BodyProperties, hair_tags etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants