Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 23, 2025

Changes proposed in this pull request

  • Changed settings file format from XML to JSON (Settings.xmlSettings.json)
  • Implemented automatic migration on first load with timestamped backups (Settings_[timestamp].xml.backup)
  • Added null-safe deserialization for both formats with descriptive exceptions
  • Extracted shared JsonOptions configuration (indented, case-insensitive, enum-to-string)
  • Refactored error handling in App.xaml.cs to eliminate duplication via HandleCorruptedSettingsFile()

Related issue(s)

N/A

Copilot generated summary

Copilot summary

Migration Logic (SettingsManager.cs):

  1. Check for Settings.json → load if exists
  2. If not found, check for Settings.xml → deserialize, save as JSON, create timestamped backup
  3. If neither exists → initialize defaults

Files Changed:

  • SettingsManager.cs: Added JSON serialization, migration logic, shared JsonOptions, null checks
  • SettingsInfo.cs: Replaced [XmlIgnore] with [JsonIgnore]
  • App.xaml.cs: Added JsonException handler, extracted common recovery logic

Safety:

  • Timestamped backups prevent overwriting (Settings_20231223140532.xml.backup)
  • Original XML preserved for manual rollback
  • Null-safe deserialization throws InvalidOperationException with clear messages
  • Corrupted files backed up before reset

JSON Configuration:

private static readonly JsonSerializerOptions JsonOptions = new()
{
    WriteIndented = true,                           // Human-readable
    PropertyNameCaseInsensitive = true,             // Flexible matching
    DefaultIgnoreCondition = JsonIgnoreCondition.Never,  // All properties
    Converters = { new JsonStringEnumConverter() }  // Enums as strings
};

To-Do

Contributing

By submitting this pull request, I confirm the following:

Original prompt

can you migrate the NETworkManager.Settings.SettingsManager to use json as new file format. The existing settings files should be automatically migrated to the new file.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Migrate SettingsManager to use JSON file format Migrate settings storage from XML to JSON with automatic migration Dec 24, 2025
Copilot AI requested a review from BornToBeRoot December 24, 2025 00:06
@BornToBeRoot BornToBeRoot added this to the next-release milestone Dec 24, 2025
@BornToBeRoot BornToBeRoot marked this pull request as ready for review December 24, 2025 16:14
@mergify mergify bot merged commit a4c7122 into main Dec 24, 2025
4 checks passed
@mergify mergify bot deleted the copilot/migrate-settings-to-json branch December 24, 2025 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants