Skip to content

Let a configuration key contain a dot - #67

Merged
74nu5 merged 1 commit into
mainfrom
fix/quoted-keys
Jul 19, 2026
Merged

Let a configuration key contain a dot#67
74nu5 merged 1 commit into
mainfrom
fix/quoted-keys

Conversation

@74nu5

@74nu5 74nu5 commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Corrige H2 de la sixième revue.

Le problème

Le point est le séparateur de chemin du langage, donc Microsoft.AspNetCore écrit nu signifiait quatre clés imbriquées. Or .NET aplatit la configuration avec un deux-points et traite le point comme un caractère ordinaire : Logging:LogLevel:Microsoft.AspNetCore — le filtre de niveau de log que toute application ASP.NET Core règle — a besoin d'un point littéral dans une seule clé.

C'était inexprimable, et l'échec était silencieux : le fichier généré avait l'air correct, le logger construisait une règle pour la catégorie Microsoft:AspNetCore, et le filtre demandé était jeté. L'exemple ASP.NET Core du README portait le défaut.

Le design

Un segment de chemin peut être une chaîne entre guillemets, acceptée partout où un identifiant l'est :

settings {
  Logging {
    LogLevel {
      "Microsoft.AspNetCore" = "Warning"   # une clé, avec un point dedans
    }
  }
  "Content-Type" = "application/json"      # et toute autre ponctuation
  Nested."A.B".C = 1                       # au milieu d'un chemin
  "My.Section" { A = 1 }                   # comme nom de bloc
}

La forme nue continue d'imbriquer, donc aucune configuration existante ne change de sens.

Une interpolation dans une clé est refusée plutôt que prise au pied de la lettre : une clé fait partie de la structure du fichier et doit être connue avant toute évaluation, donc "${x}" serait un piège dans les deux sens — le dire vaut mieux que le deviner.

Vérification

Bout en bout contre un vrai ConfigurationBuilder :

Logging:LogLevel:Default = Information
Logging:LogLevel:Microsoft.AspNetCore = Warning   ← la clé que le filtre matche
Content-Type = application/json
Nested:A.B:C = 1

Sept tests, dont deux garde-fous — le chemin pointé nu doit toujours imbriquer, et les refus doivent se déclencher. Exemple du README corrigé et fonctionnalité documentée.

384 → 391 tests.

🤖 Generated with Claude Code

Fixes H2 of the sixth cold review.

The dot is this language's path separator, so Microsoft.AspNetCore written bare
meant four nested keys. .NET flattens configuration with a colon and treats a dot
as an ordinary character, so Logging:LogLevel:Microsoft.AspNetCore — the log-level
filter every ASP.NET Core application sets — needs a literal dot inside one key.
It could not be written at all, and the failure was silent: the generated file
looked reasonable, the logger built a rule for category "Microsoft:AspNetCore",
and the filter the author asked for was discarded. The README's own ASP.NET Core
example carried the defect.

A path segment may now be a quoted string, accepted anywhere an identifier is: on
its own, in the middle of a dotted path (Nested."A.B".C), and as a nested block
name. The bare form still nests, so no existing configuration changes meaning.
It also covers keys with any other punctuation — "Content-Type" needed quoting
just as much.

An interpolation inside a key is refused rather than taken literally. A key is
part of the file's structure and has to be known before anything is evaluated, so
"${x}" would be a trap either way; saying so is better than guessing.

Verified end to end against a real ConfigurationBuilder: the generated file
flattens to Logging:LogLevel:Microsoft.AspNetCore, which is what the logging
filter matches on.

Seven tests, including two guards — the bare dotted path must still nest, and the
rejections must fire — plus the README example corrected and the feature
documented.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@74nu5
74nu5 merged commit af60d13 into main Jul 19, 2026
3 checks passed
@74nu5
74nu5 deleted the fix/quoted-keys branch July 19, 2026 20:07
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.

1 participant