microsoft / microsoft/typespec
[Bug]: http-server-csharp: Some generated model files have a generic, numbered name
- Dominant language
- Java
- Stars
- 5.9k
- Forks
- 394
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 104
Description
### Describe the bug
Supposedly, this model represents something like an operation result:
```csharp
// Generated by @typespec/http-server-csharp
//
#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;
public partial class Model10
{
///
/// The Location header contains the URL where the status of the long running operation can be checked.
///
[JsonPropertyName("location")]
public string Location { get; set; }
///
/// The Retry-After header can indicate how long the client should wait before polling the operation status.
///
[JsonPropertyName("retryAfter")]
public int? RetryAfter { get; set; }
}
```
But:
- File name: Model13.cs
- Class name: Model13
### Reproduction
1. Use an ARM RP typespec
2. Add the following to tspconfig.yaml
```yml
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
- [x] Follow our [Code of Conduct](https://github.com/microsoft/typespec/blob/main/CODE_OF_CONDUCT.md)
- [x] Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- [x] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/Microsoft/typespec/discussions).
- [x] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.
Contributor guide
Research direction
Start with the ARM RP reproduction and the @typespec/http-server-csharp emitter configured in tspconfig.yaml, then inspect the generated Model10.cs and Model13.cs files. Trace how the emitter assigns model names and verify that the operation-result model receives a meaningful name instead of a numbered one.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100