Skip to content

[Bug]: http-server-csharp: Generated createdbyType.cs has incorrect file name, XML doc #11536

Description

Describe the bug

The following file is generated:

generated@typespec\http-server-csharp\generated\models\createdByType.cs

with the following contents:

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

using System.Text.Json;
using System.Text.Json.Serialization;

namespace Microsoft.Throttling;

[JsonConverter(typeof(JsonStringEnumConverter))]
/// <summary>
/// The kind of entity that created the resource.
/// </summary>
public enum CreatedByType
{
    /// <summary>
    /// The entity was created by a user.
    /// </summary>
    [JsonStringEnumMemberName("User")]
    User,
    /// <summary>
    /// The entity was created by an application.
    /// </summary>
    [JsonStringEnumMemberName("Application")]
    Application,
    /// <summary>
    /// The entity was created by a managed identity.
    /// </summary>
    [JsonStringEnumMemberName("ManagedIdentity")]
    ManagedIdentity,
    /// <summary>
    /// The entity was created by a key.
    /// </summary>
    [JsonStringEnumMemberName("Key")]
    Key
}

Note a few issues:

  1. camel casing of the file: createdByType.cs
  2. The XML doc is below attribute [JsonConverter]
  3. Unused usings: using System.Text.Json; (minor; might be needed by other generated files)
  4. Unncessary attrubyte [JsonStringEnumMemberName] (since the enum member exactly matches the name being passed; but again - minor and might be needed by other generated files)

Reproduction

emit:

  • "@typespec/http-server-csharp"
    options:
    "@typespec/http-server-csharp":
    emitter-output-dir: "{project-root}/generated/{emitter-name}"
    output-type: all

Checklist

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions