Commit 9ba642d
[http-client-csharp] Build discriminated base description from discriminated base type, not abstract modifier (#11412)
The discriminator "Please note this is the abstract base class..."
description was only emitted when a model carried the `Abstract`
declaration modifier. Whether a discriminated base type is modeled as
abstract is an implementation detail — downstream emitters (e.g.
provisioning) may not declare it abstract, causing the derived-classes
note to be dropped.
### Changes
- **`ModelProvider`**: Added `IsDiscriminatedBaseType` helper — a model
with a discriminator property but no discriminator value.
- **`BuildDescription`**: Gates the derived-classes note on
`IsDiscriminatedBaseType` instead of the `Abstract` modifier, decoupling
documentation from abstractness.
- **`BuildDeclarationModifiers`**: Reuses the same helper for the
abstract decision, keeping the base emitter's behavior unchanged.
- **Tests**: Added
`DiscriminatedBaseDescriptionIsBuiltEvenWhenNotAbstract`, using a
`ModelProvider` subclass that strips `Abstract` to mimic a downstream
emitter and asserting the note is still built.
```csharp
private bool IsDiscriminatedBaseType =>
_inputModel.DiscriminatorProperty is not null && _inputModel.DiscriminatorValue is null;
```
<!-- START COPILOT CODING AGENT SUFFIX -->
- Fixes #11397
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>1 parent 1f7b35c commit 9ba642d
2 files changed
Lines changed: 37 additions & 4 deletions
File tree
- packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator
- src/Providers
- test/Providers/ModelProviders
Lines changed: 9 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
68 | 72 | | |
69 | 73 | | |
70 | 74 | | |
71 | 75 | | |
72 | 76 | | |
| 77 | + | |
73 | 78 | | |
74 | 79 | | |
75 | 80 | | |
| |||
324 | 329 | | |
325 | 330 | | |
326 | 331 | | |
327 | | - | |
| 332 | + | |
328 | 333 | | |
329 | 334 | | |
330 | 335 | | |
| |||
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
123 | 151 | | |
124 | 152 | | |
125 | 153 | | |
| |||
0 commit comments