Commit 1ff1962
[http-server-csharp] Emit C# class for models extending another model with no additional properties (#10175)
`isEmptyResponseModel` treats any model with zero own properties as
empty, skipping emission entirely. This means `model Baz extends Foo {}`
never produces a `Baz.cs` file, even though it's a meaningful derived
type users may want to extend via partial classes.
```typespec
model Foo { id: int32; name: string; }
model Baz extends Foo {} // No Baz.cs emitted
```
### Changes
- **`packages/http-server-csharp/src/lib/utils.ts`**:
`isEmptyResponseModel` now checks `!model.baseModel` before treating
zero-property models as empty — derived models are always emitted.
- **`packages/http-server-csharp/test/generation.test.ts`**: Added test
case verifying a model extending another with no additional properties
produces a class file with correct inheritance.
<!-- START COPILOT CODING AGENT TIPS -->
---
✨ Let Copilot coding agent [set things up for
you](https://github.com/microsoft/typespec/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: markcowl <1054056+markcowl@users.noreply.github.com>1 parent 0ee3f54 commit 1ff1962
3 files changed
Lines changed: 35 additions & 1 deletion
File tree
- .chronus/changes
- packages/http-server-csharp
- src/lib
- test
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1059 | 1059 | | |
1060 | 1060 | | |
1061 | 1061 | | |
1062 | | - | |
| 1062 | + | |
1063 | 1063 | | |
1064 | 1064 | | |
1065 | 1065 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3395 | 3395 | | |
3396 | 3396 | | |
3397 | 3397 | | |
| 3398 | + | |
| 3399 | + | |
| 3400 | + | |
| 3401 | + | |
| 3402 | + | |
| 3403 | + | |
| 3404 | + | |
| 3405 | + | |
| 3406 | + | |
| 3407 | + | |
| 3408 | + | |
| 3409 | + | |
| 3410 | + | |
| 3411 | + | |
| 3412 | + | |
| 3413 | + | |
| 3414 | + | |
| 3415 | + | |
| 3416 | + | |
| 3417 | + | |
| 3418 | + | |
| 3419 | + | |
| 3420 | + | |
| 3421 | + | |
| 3422 | + | |
| 3423 | + | |
| 3424 | + | |
0 commit comments