Skip to content

[Bug]: http-server-csharp: Generated model file fails to compile due to Unresolved Symbol: refkey #11449

Description

@abatishchev

Describe the bug

Example:

// Generated by @typespec/http-server-csharp
// <auto-generated />
#nullable enable

using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using TypeSpec.Helpers;
using TypeSpec.Helpers.JsonConverters;

namespace Microsoft.MyRpNamespace;

/// <summary>
/// Azure API Key Authentication
/// </summary>
public partial class AzureApiKeyAuthentication
{
    /// <summary>
    /// API key authentication
    /// </summary>
    [JsonPropertyName("type")]
    public <Unresolved Symbol: refkey[sSymbol(emitter-framework:csharp)⁣o28]> Type { get; set; }

    /// <summary>
    /// location of the API key
    /// </summary>
    [JsonPropertyName("in")]
    public <Unresolved Symbol: refkey[sSymbol(emitter-framework:csharp)⁣o29]> In { get; set; }

    /// <summary>
    /// name of the API key
    /// </summary>
    [JsonPropertyName("name")]
    public string Name { get; } = "Ocp-Apim-Subscription-Key";
}

result in C# compiler errors:

  • The name 'refkey' does not exist in the current context.
  • The name 'sSymbol' does not exist in the current context.
  • The name 'emitter' does not exist in the current context.
  • The name 'framework' does not exist in the current context.

Reproduction

  1. Use an ARM RP typespec
  2. Add the following to tspconfig.yaml
emit:
  - "@typespec/http-server-csharp"
options:
  "@typespec/http-server-csharp":
    emitter-output-dir: "{project-root}/generated/{emitter-name}"
    output-type: all
    emit-mocks: none
    overwrite: true

Checklist

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions