Skip to content

Add optional unescaping for section names (\. → .) #2

Description

@danny-portnov

Use case

INI files sometimes escape dots in section names using backslash:

[Section\.1]
name = value

In current SharpConfig, the section name remains "Section\.1" (with the backslash). I'd like it to be interpreted as "Section.1" for lookups and to escape automatically when saving.

Proposal

  • Add a new option like:
    var options = new ConfigurationOptions {
          UnescapeSectionNames = true
    };
    var cfg = Configuration.LoadFromFile(path, options);
  • Parse: convert "\." → "."
  • Serialize: convert "." → "\." in section headers
  • Add test cases to verify behavior

Benefits

  • Easier to write natural lookups:
var sec = cfg["Section.1"]; // works as expected

Let me know what you think or if there's an existing branch for this feature!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions