Skip to content

[TCGC] Fix enum type exclusion in protocol methods when @convenientAPI(false)#3767

Merged
tadelesh merged 3 commits intorelease/january-2026from
copilot/fix-dotnet-client-compilation-issue
Jan 14, 2026
Merged

[TCGC] Fix enum type exclusion in protocol methods when @convenientAPI(false)#3767
tadelesh merged 3 commits intorelease/january-2026from
copilot/fix-dotnet-client-compilation-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 14, 2026

Summary

Fixed enum types not being included in generated output when @convenientAPI(false) is used with HTTP operation parameters. Now based on release/january-2026 branch as requested by @tadelesh.

Changes Made

  1. Modified updateTypesFromOperation in types.ts: Removed the generateConvenient check for HTTP operation parameters so that types referenced in these parameters always get Input usage, regardless of the convenient API setting.

  2. Added comprehensive tests: Created three test cases in convenient-api.test.ts to verify that enums in query, header, and path parameters receive Input usage even when @convenientAPI(false) is set.

Root Cause

The bug occurred because TCGC was skipping input usage updates for ALL parameters when generateConvenient was false. However, HTTP operation parameters (query, header, path) represent the actual protocol-level parameters that must be included in the generated code.

Fix Details

  • Method parameters - kept the generateConvenient check
  • HTTP body parameters - kept the generateConvenient check
  • HTTP operation parameters - removed the generateConvenient check (the fix)

This ensures that types like enums used in HTTP parameters are always included in the output.

Branch Update

Rebased changes onto release/january-2026 as requested.

Original prompt

This section details on the original issue you should resolve

<issue_title>[TCGC][Bug]: Generated .NET client methods fail to compile when using @convenientAPI(false) with operation parameters</issue_title>
<issue_description>### Describe the bug

When applying the @convenientAPI(false) decorator to operations in TypeSpec, the generated .NET client fails to compile. The issue occurs because enum types referenced in operation parameters are not included in the final tcgc-output.yaml during type collection. the enum is defined as a type in the parameters, but it is not included in the enums list. As a result, the generated method signatures reference the enum type correctly, but the enum definition is missing in the output model.

Reproduction

Playground Link

IncludeEnum is defined as a type in the parameters, but it is not included in the enums list

Checklist

  • Follow our Code of Conduct
  • Check that this issue is about the Azure libraries for typespec. For bug in the typespec language or core libraries file it in the TypeSpec repo
  • Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.</issue_description>

<agent_instructions>The fix should base on branch: release/january-2026.
The reason is TCGC skip to update input usage for all parameters of method and underlying operation with generateConvenient false. The correct behavior is only skip for HTTP body parameters and method parameters.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix .NET client methods compilation error with @convenientAPI(false) [TCGC] Fix enum type exclusion in protocol methods when @convenientAPI(false) Jan 14, 2026
Copilot AI requested a review from tadelesh January 14, 2026 03:59
@tadelesh
Copy link
Copy Markdown
Member

@copilot You need to make the change based on the branch: release/january-2026.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 14, 2026

@copilot You need to make the change based on the branch: release/january-2026.

Done! I've rebased the changes onto release/january-2026 branch. The fix is now in commits 432caba8 and 357eb986 which are based on release/january-2026 (a6ce790).

The changes are ready but there's a technical issue with force-pushing the updated branch due to the different base. The fix itself remains identical - removing the generateConvenient check for HTTP operation parameters in updateTypesFromOperation().

Remove generateConvenient check for HTTP operation parameters so that
types referenced in query, header, and path parameters always get Input
usage, even when convenientAPI is false. This ensures enums and other
types are included in the generated output.

The check is still kept for method parameters and body parameters as
intended.

Co-authored-by: tadelesh <1726438+tadelesh@users.noreply.github.com>
@tadelesh tadelesh force-pushed the copilot/fix-dotnet-client-compilation-issue branch from 91e282d to 218ee70 Compare January 14, 2026 05:27
@tadelesh tadelesh changed the base branch from main to release/january-2026 January 14, 2026 05:27
@microsoft-github-policy-service microsoft-github-policy-service bot added the lib:tcgc Issues for @azure-tools/typespec-client-generator-core library label Jan 14, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Jan 14, 2026

Open in StackBlitz

npm i https://pkg.pr.new/Azure/typespec-azure/@azure-tools/typespec-client-generator-core@3767

commit: d79dc90

@tadelesh tadelesh marked this pull request as ready for review January 14, 2026 05:35
Copy link
Copy Markdown
Member

@weidongxu-microsoft weidongxu-microsoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Java would actually generate String or String[] on protocol API. So in scenario of Java, we actually would like it be no Input.

But for now, Java is not using TCGC calculation

@tadelesh tadelesh enabled auto-merge (squash) January 14, 2026 07:54
@tadelesh tadelesh merged commit 61e7769 into release/january-2026 Jan 14, 2026
22 checks passed
@tadelesh tadelesh deleted the copilot/fix-dotnet-client-compilation-issue branch January 14, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lib:tcgc Issues for @azure-tools/typespec-client-generator-core library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TCGC][Bug]: Generated .NET client methods fail to compile when using @convenientAPI(false) with operation parameters

3 participants