Skip to content

fix(generators): escape .WithName label in ProfilerMarkers output#143

Merged
VPDPersonal merged 1 commit into
mainfrom
worktree-fix+profilermarkers-escape-withname-label
Jul 7, 2026
Merged

fix(generators): escape .WithName label in ProfilerMarkers output#143
VPDPersonal merged 1 commit into
mainfrom
worktree-fix+profilermarkers-escape-withname-label

Conversation

@VPDPersonal

Copy link
Copy Markdown
Owner

Summary

  • 🐛 The ProfilerMarkers generator inlined the .WithName("...") label into generated C# without escaping, so a label containing quotes, backslashes or braces produced source that failed to compile. Every marker literal fragment now goes through a ToLiteral escape helper.
  • ♻️ The generic (arity > 0) path now builds the label by concatenating escaped literals with typeof(T).Name instead of emitting one interpolated string, so braces in the label are no longer treated as interpolation holes.
  • ✅ Added regression tests for special characters and for braces on a generic type — both compile the generated source via AssertNoErrors. Generators suite: 38/38.

Notes for review

  • ⚠️ The generic marker value changes shape in the generated code (concatenation instead of an interpolated string) but the runtime string is identical — the per-instantiation typeof(T).Name is preserved.
  • 🔧 The committed Aspid.FastTools.Generators.dll is the rebuilt deployment artifact for this fix.
🇷🇺 Описание на русском

Сводка

  • 🐛 Генератор ProfilerMarkers вставлял метку .WithName("...") в генерируемый C# без экранирования, поэтому метка с кавычками, обратными слешами или фигурными скобками давала несобираемый код. Теперь все фрагменты литерала маркера проходят через хелпер ToLiteral.
  • ♻️ Ветка для generic-типа (arity > 0) собирает метку конкатенацией экранированных литералов с typeof(T).Name вместо интерполированной строки, так что фигурные скобки в метке больше не считаются дырами интерполяции.
  • ✅ Добавлены регрессионные тесты на спецсимволы и на скобки в generic-типе — оба компилируют сгенерированный код через AssertNoErrors. Набор генераторов: 38/38.

Заметки для ревью

  • ⚠️ Значение маркера для generic-типа меняет форму в сгенерированном коде (конкатенация вместо интерполяции), но итоговая строка идентична — подстановка typeof(T).Name на инстанс сохранена.
  • 🔧 Закоммиченный Aspid.FastTools.Generators.dll — пересобранный артефакт деплоя для этого фикса.

- Emit marker literal fragments through a ToLiteral escape helper so a
  .WithName("...") label with quotes or backslashes no longer breaks the
  generated string literal.
- Build the generic (arity > 0) label by concatenating escaped literals with
  typeof(T).Name instead of one interpolated string, so braces in the label are
  not treated as interpolation holes.
- Add regression tests for special characters and braces on a generic type.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BiBGPPKYdunqf8wb1xe5Xi
@VPDPersonal VPDPersonal added type: fix Bug fix status: work-in-progress Draft / not ready for review area: generator Roslyn source generator labels Jul 7, 2026
@VPDPersonal VPDPersonal marked this pull request as ready for review July 7, 2026 19:21
@VPDPersonal VPDPersonal merged commit e04b07e into main Jul 7, 2026
5 checks passed
@VPDPersonal VPDPersonal deleted the worktree-fix+profilermarkers-escape-withname-label branch July 7, 2026 19:21
@github-actions github-actions Bot added status: needs-review Ready for review and removed status: work-in-progress Draft / not ready for review status: needs-review Ready for review labels Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: generator Roslyn source generator type: fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant