Repository navigation
Feature: Added --check option to cadl format - #47
Merged
Timothee Guerin (timotheeguerin) merged 3 commits intoNov 8, 2021
Merged
Timothee Guerin (timotheeguerin) merged 3 commits into
Timothee Guerin (timotheeguerin) merged 3 commits into
Conversation
Nick Guerrera (nguerrera)
approved these changes
Nov 8, 2021
om singhal (Om-singhaI)
pushed a commit
to Om-singhaI/typespec
that referenced
this pull request
Aug 27, 2026
…osoft#11766) ## Summary Fixes generated Java code corruption when a Javadoc table cell (parameter name/type/description, or response header name/type/description) contains a literal `*/` sequence. ## Root cause Values written into the optional-parameters and response-headers Javadoc tables are escaped for XML special characters via `CodeNamer.escapeXmlComment`, but never comment-escaped. When a value embeds `*/` (for example, TCGC's Content-Type parameter doc for an unconstrained `Http.File` content type, whose `contentTypes` array is `["*/*"]`), the literal `*/` prematurely closes the surrounding generated `/** ... */` Javadoc block. This corrupts the rest of the generated Java file and breaks compilation with a long cascade of parser errors. ## Fix `CodeNamer.escapeComment` already exists and correctly escapes `*/` to `*µsoft#47;`, but it wasn't applied consistently. This change centralizes the escaping in the shared `ClientMethodTemplateBase#javadocTable` helper so every cell value (not just parameter descriptions) is protected, alongside the existing XML escaping. ## Context Found while fixing Azure/typespec-azure#5288 (Azure/typespec-azure#5306), where making the Content-Type parameter for default `Http.File` bodies client-visible (previously hidden as a constant) surfaced this latent Javadoc-escaping bug in CI. --------- Co-authored-by: iscai-msft <isabellavcai@gmail.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6a785543-019d-4b0c-9750-5affcfc900ee
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added
--checkoption similar torust fmt --checkto add some option for user to validate files are formatted without having to useprettierdirectly.Realized we were missing this and to ensure cadl user can make sure they code is formatted, I believe this is required.
Example running

cadl format **/*.cadl --checkin this repo: