Skip to content

Add CsTomlFileSerializer.Deserialize/DeserializeAsync/Serialize/SerializeAsync overload accepting TomlFileExtensionPolicy#103

Merged
prozolic merged 2 commits into
mainfrom
fileextensions
May 11, 2026
Merged

Add CsTomlFileSerializer.Deserialize/DeserializeAsync/Serialize/SerializeAsync overload accepting TomlFileExtensionPolicy#103
prozolic merged 2 commits into
mainfrom
fileextensions

Conversation

@prozolic

@prozolic prozolic commented May 11, 2026

Copy link
Copy Markdown
Owner

#102

This PR add CsTomlFileSerializer.Deserialize/DeserializeAsync/Serialize/SerializeAsync overload accepting TomlFileExtensionPolicy.

public partial class CsTomlFileSerializer
{
    public static T Deserialize<T>(string tomlFilePath, CsTomlSerializerOptions? options, TomlFileExtensionPolicy extensionPolicy);
    public static ValueTask<T> DeserializeAsync<T>(string tomlFilePath, CsTomlSerializerOptions? options, TomlFileExtensionPolicy extensionPolicy, bool configureAwait = false, CancellationToken cancellationToken = default);
    public static void Serialize<T>(string tomlFilePath, T value, CsTomlSerializerOptions? options, TomlFileExtensionPolicy extensionPolicy);
    public static ValueTask SerializeAsync<T>(string tomlFilePath, T value, CsTomlSerializerOptions? options, TomlFileExtensionPolicy extensionPolicy, bool configureAwait = false, CancellationToken cancellationToken = default);
}

public enum TomlFileExtensionPolicy
{
    Strict = 0,
    Relaxed = 1
}

…lizeAsync overload accepting TomlFileExtensionPolicy
Copilot AI review requested due to automatic review settings May 11, 2026 14:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses issue #102 by adding an opt-in mechanism to relax the .toml file-extension requirement in CsTomlFileSerializer through new overloads that accept a TomlFileExtensionPolicy.

Changes:

  • Added TomlFileExtensionPolicy enum (Strict / Relaxed) in CsToml.Extensions.
  • Added Deserialize / DeserializeAsync / Serialize / SerializeAsync overloads that accept TomlFileExtensionPolicy, with the existing overloads forwarding to Strict.
  • Added test coverage validating strict vs relaxed behavior across sync/async and serialize/deserialize paths.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
tests/CsToml.Tests/CsTomlFileSerializerExtensionPolicyTest.cs Adds unit tests covering strict vs relaxed extension behavior across sync/async APIs.
src/CsToml.Extensions/TomlFileExtensionPolicy.cs Introduces the TomlFileExtensionPolicy enum used by new overloads.
src/CsToml.Extensions/CsTomlFileSerializer.cs Adds new overloads and centralizes extension validation logic via ValidateExtension.

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

Comment thread src/CsToml.Extensions/CsTomlFileSerializer.cs
Comment thread src/CsToml.Extensions/CsTomlFileSerializer.cs Outdated
Comment thread src/CsToml.Extensions/CsTomlFileSerializer.cs
Comment thread src/CsToml.Extensions/CsTomlFileSerializer.cs
Comment thread src/CsToml.Extensions/CsTomlFileSerializer.cs Outdated
Comment thread src/CsToml.Extensions/CsTomlFileSerializer.cs
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