Skip to content

[Bug]: Unable to emit @typespec/http-server-csharp using azure-rest-api-specs typespec #8500

@AntonioVT

Description

@AntonioVT

Describe the bug

Considering the PR and branch containerregistry-conversion, I run into issues when trying to compile typespec with emit option "@typespec/http-server-csharp".

Log:

> tsp compile specs/containerregistry/main.tsp

TypeSpec compiler v1.4.0

✔ Compiling
✔ @azure-tools/typespec-autorest 819ms specs/containerregistry/
× Running @typespec/http-server-csharp...
Emitter "@typespec/http-server-csharp" crashed! This is a bug.
Please file an issue at https://github.com/microsoft/typespec/issues

Error: Encountered type TemplateParameter which we don't know how to emit.
    at compilerAssert (file:///C:/work/acr/dev/src/ACR.RP/ACR.RP.Web.Spec/node_modules/@typespec/compiler/dist/src/core/diagnostics.js:150:11)
    at typeEmitterKey (file:///C:/work/acr/dev/src/ACR.RP/ACR.RP.Web.Spec/node_modules/@typespec/asset-emitter/dist/src/asset-emitter.js:618:17)
    at Object.emitType (file:///C:/work/acr/dev/src/ACR.RP/ACR.RP.Web.Spec/node_modules/@typespec/asset-emitter/dist/src/asset-emitter.js:238:25)
    at #resolveOperationResponse (file:///C:/work/acr/dev/src/ACR.RP/ACR.RP.Web.Spec/node_modules/@typespec/http-server-csharp/dist/src/lib/service.js:744:26)
    at CSharpCodeEmitter.interfaceDeclarationOperations (file:///C:/work/acr/dev/src/ACR.RP/ACR.RP.Web.Spec/node_modules/@typespec/http-server-csharp/dist/src/lib/service.js:586:77)
    at file:///C:/work/acr/dev/src/ACR.RP/ACR.RP.Web.Spec/node_modules/@typespec/asset-emitter/dist/src/asset-emitter.js:376:55
    at withTypeContext (file:///C:/work/acr/dev/src/ACR.RP/ACR.RP.Web.Spec/node_modules/@typespec/asset-emitter/dist/src/asset-emitter.js:519:9)
    at invokeTypeEmitter (file:///C:/work/acr/dev/src/ACR.RP/ACR.RP.Web.Spec/node_modules/@typespec/asset-emitter/dist/src/asset-emitter.js:366:9)
    at Object.emitInterfaceOperations (file:///C:/work/acr/dev/src/ACR.RP/ACR.RP.Web.Spec/node_modules/@typespec/asset-emitter/dist/src/asset-emitter.js:327:20)
    at CSharpCodeEmitter.interfaceDeclaration (file:///C:/work/acr/dev/src/ACR.RP/ACR.RP.Web.Spec/node_modules/@typespec/http-server-csharp/dist/src/lib/service.js:542:22)

--------------------------------------------------
Library Version                0.58.0-alpha.20
TypeSpec Compiler Version      1.4.0
--------------------------------------------------

My configuration looks as follows:

emit:
  - "@azure-tools/typespec-autorest"
  - "@typespec/http-server-csharp"
options:
  ...
  "@typespec/http-server-csharp":
    emitter-output-dir: "{project-root}/typespec/codegen"
    output-type: "models"
    collection-type: "enumerable"

Surprised, considering that emitter "@azure-tools/typespec-autorest" works as expected, and also used the "@typespec/openapi3" to further verify, and it works as expected. But for some reason, the csharp generator runs into an issue.

Reproduction

The description is pretty straightforward.
I will go ahead and create a fork so you may clone and reproduce locally, and update the thread.

Checklist

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions