Skip to content

Add OriginalName to InputOperation to prevent CollectionResult name collisions#10021

Merged
jorgerangel-msft merged 11 commits intomainfrom
copilot/update-input-operation-original-name
Mar 13, 2026
Merged

Add OriginalName to InputOperation to prevent CollectionResult name collisions#10021
jorgerangel-msft merged 11 commits intomainfrom
copilot/update-input-operation-original-name

Conversation

Copy link
Contributor

Copilot AI commented Mar 13, 2026

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
Original prompt

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)


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

…esultDefinition.BuildName

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Mar 13, 2026
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix CollectionResults type name collisions Add OriginalName to InputOperation to prevent CollectionResult name collisions Mar 13, 2026
Copilot AI requested a review from jorgerangel-msft March 13, 2026 19:03
Copilot AI and others added 2 commits March 13, 2026 19:10
…ion and no-collision tests

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
…sync+async × 2 ops)

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
…r and test factory

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 13, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 1oavsblobprodcus350.vsblob.vsassets.io
    • Triggering command: /tmp/codeql-scratch-ffd2291efb7cde48/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-ffd2291efb7cde48/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /home/REDACTED/work/typespec/typespec/docs/samples/client/csharp/plugins/logging/Logging.Plugin/src/Logging.Plugin.csproj --packages /tmp/codeql-scratch-ffd2291efb7cde48/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-ffd2291efb7cde48/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-ffd2291efb7cde48/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true ng/emptyFakeDotnetRoot ing/emptyFakeDotnetRoot dnx cal/bin/git (dns block)
  • 5dkvsblobprodcus355.vsblob.vsassets.io
    • Triggering command: /tmp/codeql-scratch-ffd2291efb7cde48/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-ffd2291efb7cde48/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /tmp/codeql-scratch-ffd2291efb7cde48/dbs/csharp/working/C31F48A60590A971E376753BAE25D343/missingpackages_workingdir --packages /tmp/codeql-scratch-ffd2291efb7cde48/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /tmp/codeql-scratch-ffd2291efb7cde48/dbs/csharp/working/nugetconfig/nuget.config --force (dns block)
  • k4kvsblobprodcus344.vsblob.vsassets.io
    • Triggering command: /tmp/codeql-scratch-ffd2291efb7cde48/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-ffd2291efb7cde48/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /tmp/codeql-scratch-ffd2291efb7cde48/dbs/csharp/working/E6B8F2860FE6D554D9E0F93A282FEAAC/missingpackages_workingdir --packages /tmp/codeql-scratch-ffd2291efb7cde48/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /tmp/codeql-scratch-ffd2291efb7cde48/dbs/csharp/working/nugetconfig/nuget.config --force (dns block)
  • kxqvsblobprodcus376.vsblob.vsassets.io
    • Triggering command: /tmp/codeql-scratch-ffd2291efb7cde48/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-ffd2291efb7cde48/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /tmp/codeql-scratch-ffd2291efb7cde48/dbs/csharp/working/C31F48A60590A971E376753BAE25D343/missingpackages_workingdir --packages /tmp/codeql-scratch-ffd2291efb7cde48/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /tmp/codeql-scratch-ffd2291efb7cde48/dbs/csharp/working/nugetconfig/nuget.config --force (dns block)
  • xupvsblobprodcus332.vsblob.vsassets.io
    • Triggering command: /tmp/codeql-scratch-ffd2291efb7cde48/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-ffd2291efb7cde48/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /tmp/codeql-scratch-ffd2291efb7cde48/dbs/csharp/working/C31F48A60590A971E376753BAE25D343/missingpackages_workingdir --packages /tmp/codeql-scratch-ffd2291efb7cde48/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /tmp/codeql-scratch-ffd2291efb7cde48/dbs/csharp/working/nugetconfig/nuget.config --force (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 13, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-csharp@10021

commit: 31f8a6f

@jorgerangel-msft jorgerangel-msft added this pull request to the merge queue Mar 13, 2026
Merged via the queue into main with commit f4f2f32 Mar 13, 2026
24 checks passed
@jorgerangel-msft jorgerangel-msft deleted the copilot/update-input-operation-original-name branch March 13, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The generator should make sure CollectionResults types never collide names with each other

3 participants