microsoft / microsoft/typespec
[http-server-csharp] Support omit-unreachable-types setting in config to exclude types not used in operations
- Dominant language
- Java
- Stars
- 5.9k
- Forks
- 394
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 104
Description
I am generating [the petstore spec](https://github.com/microsoft/typespec/tree/main/packages/samples/specs/petstore),
the model `PetId` is not really used, we use it to spread it as parameters:
```
op create(...PetId): Pet;
```
but this model is actually not used.
The server gen still generates it, and it cannot compile because this model has a property with the same name as the model.
```csharp
public partial class PetId
{
public int PetId {get; set;} // this will not compile.
}
```
Either, the server gen should not generate the model that is not used, or we should do something on the generated model to ensure it never has a property with the same name as its enclosing type.
Or I think we should do both.
Contributor guide
Assessment
This issue has not been assessed yet.