You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: http-server-csharp: Generated createdbyType.cs has incorrect file name, XML doc #11536
// Generated by @typespec/http-server-csharp// <auto-generated />
#nullable enable
usingSystem.Text.Json;usingSystem.Text.Json.Serialization;namespaceMicrosoft.Throttling;[JsonConverter(typeof(JsonStringEnumConverter))]/// <summary>/// The kind of entity that created the resource./// </summary>publicenumCreatedByType{/// <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:
camel casing of the file: createdByType.cs
The XML doc is below attribute [JsonConverter]
Unused usings: using System.Text.Json; (minor; might be needed by other generated files)
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
The @typespec/http-server-csharp emitter generates createdByType.cs with incorrect camelCase filename (should be CreatedByType.cs), and places the [JsonConverter] attribute above the XML doc comment block instead of below it.
File naming: createdByType.cs — C# convention requires PascalCase filenames matching the type name: CreatedByType.cs
XML doc placement: The [JsonConverter(typeof(JsonStringEnumConverter))] attribute is emitted before the XML doc comment (/// ...). In C#, XML documentation comments must appear immediately before the declaration, so attributes should come after the docs or the docs will not be correctly associated.
(Minor) Unused using System.Text.Json; import
(Minor) Redundant [JsonStringEnumMemberName] attributes where member name matches the string value
The root cause is in the code generation logic for enum types in the C# service emitter — specifically how file paths are computed and how attributes/docs are ordered during output rendering.
📝 Suggested next steps
Fix file name generation to use PascalCase for enum types (and verify consistency across all generated type files)
Fix ordering: emit XML doc comments before attributes in enum and possibly other type declarations
(Optional) Suppress redundant [JsonStringEnumMemberName] when name matches value exactly
Activity
github-actions commentedon Aug 4, 2026
🎯 Issue Triage
The
@typespec/http-server-csharpemitter generatescreatedByType.cswith incorrect camelCase filename (should beCreatedByType.cs), and places the[JsonConverter]attribute above the XML doc comment block instead of below it.Category: Bug
Area:
emitter:service:csharp🔍 Analysis
Affected component:
@typespec/http-server-csharpemitterIssues identified:
createdByType.cs— C# convention requires PascalCase filenames matching the type name:CreatedByType.cs[JsonConverter(typeof(JsonStringEnumConverter))]attribute is emitted before the XML doc comment (/// ...). In C#, XML documentation comments must appear immediately before the declaration, so attributes should come after the docs or the docs will not be correctly associated.using System.Text.Json;import[JsonStringEnumMemberName]attributes where member name matches the string valueThe root cause is in the code generation logic for enum types in the C# service emitter — specifically how file paths are computed and how attributes/docs are ordered during output rendering.
📝 Suggested next steps
[JsonStringEnumMemberName]when name matches value exactlytimotheeguerin commentedon Aug 7, 2026
Not sure if that is the exact same repro but seems like we just don't apply naming policy on the file
playground
Fix C# server model filenames (microsoft#11591)