Fix preview API version detection for const-based codegen pattern - #26761
Conversation
…rn from autorest.go PR #1944 Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-go/sessions/a77da1d3-82c0-40c1-9b92-6205fbab752a Co-authored-by: JiaqiZhang-Dev <194873822+JiaqiZhang-Dev@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-go/sessions/85108293-9e2e-41cf-a788-e1e1aeb7de33 Co-authored-by: JiaqiZhang-Dev <194873822+JiaqiZhang-Dev@users.noreply.github.com>
Chenjie Shi (tadelesh)
left a comment
There was a problem hiding this comment.
Could you add the changelog and bump version?
There was a problem hiding this comment.
Pull request overview
This PR updates the generator’s preview API version detection logic to recognize a const-based API version pattern (in addition to inline "api-version" usage), and adds unit tests for the new detection case.
Changes:
- Add
apiVersionConstRegexand extendcontainsPreviewAPIVersion()to detect preview API versions declared via adefault*Versionconst. - Add unit tests covering preview/stable const-based API version declarations.
- Apply
gofmtalignment changes in the regex var block.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| eng/tools/generator/version/version_tool.go | Adds a new regex and detection branch for const-based preview API version detection. |
| eng/tools/generator/version/version_tool_test.go | Adds tests to validate the new const-based detection behavior. |
Copilot pls help add the changelog and bump version for generator |
Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-go/sessions/3a4f4503-9b34-4d9e-a447-971488c2fcb4 Co-authored-by: JiaqiZhang-Dev <194873822+JiaqiZhang-Dev@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-go/sessions/3d11e51c-38eb-45f9-895a-6196c94027e7 Co-authored-by: JiaqiZhang-Dev <194873822+JiaqiZhang-Dev@users.noreply.github.com>
Chenjie Shi (tadelesh)
left a comment
There was a problem hiding this comment.
How could current logic handle multiple services case?
|
autorest.go#1944 moved API version literals from inline usage to per-client consts, breaking
containsPreviewAPIVersionin the generator.Before (inline literal — old codegen):
After (const declaration — new codegen):
The detector only matched the inline pattern via
"api-version"string splitting, so it stopped finding preview versions in newly generated code.Changes
apiVersionConstRegexto matchconst default<Name>Version string = "..."declarationscontainsPreviewAPIVersionnow checks both the inline and const patterns