Skip to content

[MPG C# Generator] Paging action operations should not resource-wrap return types #57110

@haiyuazhang

Description

@haiyuazhang

Bug Description

The MPG C# generator incorrectly wraps paging results in resource types for action operations. When a paging operation is an ARM action (not a list), the generator should return the raw data type (e.g., Pageable<ServerConfigurationData>), not the resource-wrapped type (e.g., Pageable<NodeConfigurationResource>).

Example TypeSpec: ServerConfiguration.tsp — the listByServer operation is an ArmResourceActionSync (action on ClusterServer), not a resource list on ServerConfiguration.

tspCodeModel evidence

The emitter correctly identifies the operation as an Action in the resource metadata:

{
    "methodId": "Microsoft.DBforPostgreSQL.Configurations.listByServer",
    "kind": "Action",
    "operationPath": ".../{clusterName}/servers/{serverName}/configurations",
    "resourceScope": ".../{clusterName}/servers/{serverName}"
}

However, the method-level metadata only says kind: "paging" — the Action vs List distinction is only in the resource operation metadata.

Expected behavior

Since the operation is an Action (not a List), the generated method should return:

public virtual Pageable<CosmosDBForPostgreSqlServerConfigurationData> GetConfigurations(...)

Actual behavior

The generator sees the paging kind + a matching NodeConfigurationResource class, and produces:

public virtual Pageable<CosmosDBForPostgreSqlNodeConfigurationResource> GetConfigurations(...)

Root cause

The generator does not check the ARM resource operation kind (Action vs List) when deciding whether to resource-wrap paging results. It only checks the method-level kind: "paging" and the existence of a matching resource class.

Current workaround

Use CodeGenSuppress in a Customized/ file to suppress the generated method and replace it with a hand-written version returning the raw data type.

Metadata

Metadata

Labels

CodeGenIssues that relate to code generationMgmtThis issue is related to a management package.

Type

No type

Projects

Status

🎊 Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions