Skip to content

Flatten DTO option parameters in Go polyglot generator #17664

@davidfowl

Description

@davidfowl

Problem

The Go polyglot generator currently nests an optional DTO parameter inside the generated method-options wrapper when the C# API has an optional parameter named options.

For example, the Foundry hosted-agent API currently generates a Go call shape like:

hostedAgent.AsHostedAgent(project, &aspire.AsHostedAgentOptions{
    Options: &aspire.HostedAgentOptions{
        Description: "Validation hosted agent",
        Cpu: aspire.Float64Ptr(1),
        Memory: aspire.Float64Ptr(2),
    },
})

This is awkward because there are two different options concepts:

  • AsHostedAgentOptions: the generated Go wrapper for optional method parameters
  • HostedAgentOptions: the DTO that represents the actual API options payload

TypeScript already flattens this scenario into the user-facing DTO shape:

await hostedAgent.asHostedAgent(project, {
    description: "Validation hosted agent",
    cpu: 1,
    memory: 2
});

Expected behavior

The Go generator should apply equivalent flattening for optional DTO parameters so Go callers do not have to write Options: &HostedAgentOptions{ ... } when the optional parameter is itself the exported DTO/options payload.

Notes

This came up while updating the Foundry hosted-agent polyglot fixtures in PR #17545. That PR keeps the generated Go shape as-is and should not take the generator fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-polyglotIssues related to polyglot apphoststriage:bot-seenAspire triage bot has seen this issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions