Skip to content

Feat/toml config support#70

Closed
T3Marius wants to merge 2 commits into
swiftly-solution:masterfrom
T3Marius:feat/toml-config-support
Closed

Feat/toml config support#70
T3Marius wants to merge 2 commits into
swiftly-solution:masterfrom
T3Marius:feat/toml-config-support

Conversation

@T3Marius
Copy link
Copy Markdown
Contributor

@T3Marius T3Marius commented Nov 3, 2025

Description

Refactored TOML configuration serialization to use Tomlyn's built-in FromModel() method instead of custom reflection-based conversion, simplifying the codebase and improving maintainability.

Type of Change

  • Code refactoring (no functional changes)
  • Performance improvement

Related Issues

N/A

Changes Made

  • Managed Changes (C#)

Detailed Changes

  • Removed the entire TomlModelHelper static class (117 lines of custom reflection code)
  • Refactored InitializeTomlWithModel to use Tomlyn's native Toml.FromModel() serialization
  • Cleaned up unused imports (System.Diagnostics.CodeAnalysis, System.Reflection, Tomlyn.Model)
  • Simplified TOML serialization logic from ~30 lines to ~10 lines

Testing

Test Environment

  • OS: Windows 11
  • Game: Counter-Strike 2

Test Cases

  1. Built the managed project successfully with no new errors
  2. Verified TOML configuration file generation works correctly
  3. Confirmed all existing functionality remains intact

Breaking Changes

None - This is a pure refactoring with no API or functionality changes.

Performance Impact

  • Positive performance impact

Details: Using Tomlyn's optimized built-in serialization instead of custom reflection should provide better performance and reliability.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Additional Notes

This refactoring improves code maintainability by leveraging Tomlyn's tested and optimized serialization capabilities instead of maintaining custom reflection-based conversion logic. The approach now matches the pattern used for JSON configuration, providing consistency across the codebase.

…ction

- Replace custom TomlModelHelper class with Toml.FromModel()
- Remove 117 lines of manual reflection-based TOML conversion
- Simplify InitializeTomlWithModel to use native Tomlyn serialization
- Clean up unused imports (System.Diagnostics.CodeAnalysis, System.Reflection, Tomlyn.Model)
- Improve code maintainability and reliability
@samyycX samyycX closed this Nov 3, 2025
@samyycX samyycX mentioned this pull request Nov 4, 2025
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