Commit f4f2f32
Add OriginalName to InputOperation to prevent CollectionResult name collisions (#10021)
`CollectionResultDefinition.BuildName()` derives its type name from
`Operation.Name`, which is mutable via `InputOperation.Update()`. When
multiple operations get renamed to the same name (e.g., `List` and
`ListAll` both becoming `GetAll` via `CleanOperationNames`), their
CollectionResult types collide.
`BuildName()` now detects collisions by checking if another paging
operation in the same client would produce the same name, and only falls
back to `OriginalName` when a collision is detected. When there is no
collision, the current (cleaned) name is used as before.
### Changes
- **`InputOperation`** — Added nullable `OriginalName` property
(`string?`), never modified by `Update()`, with no default assignment
- **`InputOperationConverter`** — Set `OriginalName` during
deserialization (sole assignment point for production code)
- **`ClientProvider`** — Exposed `_inputClient` as an `internal
InputClient` property so `CollectionResultDefinition` can access the
client's methods for collision detection
- **`CollectionResultDefinition.BuildName()`** — Added
`HasPagingOperationNameCollision()` check; uses `OriginalName` (with
null fallback to `Operation.Name`) only when another paging operation in
the same client would produce the same name
- **`CollectionResultDefinitionTests`** — Added collision test (two ops
`list`+`listAll` both renamed to `GetAll` produce unique names) and
no-collision test (single op uses cleaned name)
- **`InputFactory`** — Updated test factory to explicitly set
`OriginalName` after construction
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>The generator should make sure CollectionResults types
never collide names with each other</issue_title>
> <issue_description>Mirror issue of
Azure/azure-sdk-for-net#57063, but for the
unbranded generator. </issue_description>
>
> <agent_instructions>Lets fix this by updating InputOperation to have a
new public `OriginalName` string property which will contain the
original name of the operation before any mutations are done on it. Then
in `CollectionResultDefinition` we should simply use OriginalName inside
the BuildName override when constructing the name. This should work
since typespec doesn't allow duplicate operation names within a
client.</agent_instructions>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> </comments>
>
</details>
<!-- START COPILOT CODING AGENT SUFFIX -->
- Fixes #10020
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 Send tasks to Copilot coding agent from
[Slack](https://gh.io/cca-slack-docs) and
[Teams](https://gh.io/cca-teams-docs) to turn conversations into code.
Copilot posts an update in your thread when it's finished.
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: jorgerangel-msft <[email protected]>1 parent a22a859 commit f4f2f32
File tree
6 files changed
+113
-2
lines changed- packages/http-client-csharp/generator
- Microsoft.TypeSpec.Generator.ClientModel
- src/Providers
- test/Providers/CollectionResultDefinitions
- Microsoft.TypeSpec.Generator.Input/src/InputTypes
- Serialization
- Microsoft.TypeSpec.Generator/test/common
6 files changed
+113
-2
lines changedLines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
Lines changed: 28 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
186 | 213 | | |
187 | 214 | | |
188 | 215 | | |
| |||
Lines changed: 75 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
208 | 283 | | |
209 | 284 | | |
210 | 285 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
76 | 81 | | |
77 | 82 | | |
78 | 83 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
639 | 639 | | |
640 | 640 | | |
641 | 641 | | |
642 | | - | |
| 642 | + | |
643 | 643 | | |
644 | 644 | | |
645 | 645 | | |
| |||
658 | 658 | | |
659 | 659 | | |
660 | 660 | | |
| 661 | + | |
| 662 | + | |
661 | 663 | | |
662 | 664 | | |
663 | 665 | | |
| |||
0 commit comments