Skip to content

Conversation

@ting-liang-rocketwerkz
Copy link
Contributor

Added a new TomlFieldAttribute
Updated TomlCompositeSerializer/TomlCompositeDeserializer to work with TomlFieldAttribute

Example usage:

Before:

[TomlDoNotInlineObject]
public class GameSettings
{
    public enum DisplayMode
    {
        Windowed = 0,
        Fullscreen = 1,
    }
    
    [TomlProperty("display.mode")]
    public DisplayMode ScreenDisplayMode { get; set; } = DisplayMode.Fullscreen;
}
// ...
var mode = _temporary.ScreenDisplayMode;
if (
    ImGuiHelper.DrawCombo(
        GameStrings.Mode,
        ref mode,
        EnumCollections.DisplayModes,
        mode != Current.ScreenDisplayMode
    )
)
    _temporary.ScreenDisplayMode = mode;

After:

[TomlDoNotInlineObject]
public class GameSettings
{
    public enum DisplayMode
    {
        Windowed = 0,
        Fullscreen = 1,
    }
    
    [TomlField("display.mode")]
    public DisplayMode ScreenDisplayMode = DisplayMode.Fullscreen;
}
// ...
ImGuiHelper.DrawCombo(
    GameStrings.Mode,
    ref _temporary.ScreenDisplayMode,
    EnumCollections.DisplayModes,
    _temporary.ScreenDisplayMode != Current.ScreenDisplayMode
);

@SamboyCoding SamboyCoding merged commit f8e94b2 into SamboyCoding:master Mar 3, 2025
1 check passed
@coveralls
Copy link

Pull Request Test Coverage Report for Build 13620450615

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 15 of 22 (68.18%) changed or added relevant lines in 3 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.3%) to 91.406%

Changes Missing Coverage Covered Lines Changed/Added Lines %
Tomlet/Attributes/TomlFieldAttribute.cs 0 7 0.0%
Files with Coverage Reduction New Missed Lines %
Tomlet/TomlCompositeDeserializer.cs 1 93.6%
Totals Coverage Status
Change from base Build 13549081360: -0.3%
Covered Lines: 1925
Relevant Lines: 2106

💛 - Coveralls

@ting-liang-rocketwerkz ting-liang-rocketwerkz deleted the feat-add-toml-field-attribute-54 branch March 3, 2025 21:34
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.

3 participants