Azure / autorest.csharp

Extension for AutoRest (https://github.com/Azure/autorest) that generates C# code
MIT License
141 stars 166 forks source link

Decide on our story for flattening DPG-generated models in .NET #2364

Open annelo-msft opened 2 years ago

annelo-msft commented 2 years ago

Per @m-nash:

Is there any position on flattening single property models? I know flattening in general has some pitfalls but in MPG we were able to come up with a way that is safe for single property models. It is common practice in mgmt plane to make place holder models even if it starts with 1 property to be able to add things in the future, but initially it makes the client harder to work with.

[Description TBD]

m-nash commented 1 year ago

@KrzysztofCwalina and @tg-msft Do you guys have an opinion on this?

In management plane this was more valuable because we didn't necessarily analyze the structure of every model due to sheer volume. In data plane there will be a lot more scrutiny on each model and if we decide that a model with one property is appropriate that means we most likely believe there is a high likelihood of getting more properties later.

For reference here is an example of the pattern in mgmt plane when we hide a 1 property model. Our release valve if the single property model gets a second property is to make the internal property public and EB.Never the unwrapped property.

My recommendation here would be to not have this on by default but potentially be able to opt into this for specific scenarios. The reason being is the release valve explained above is not exactly ideal but in management plane case we believe that the overwhelming majority of of the single property models will never get a second property so it should be rare we have to enable the release valve. In dataplane given we will curate models more the opposite will most likely be true.

chunyu3 commented 1 year ago

For dataplane, archboard will review typespec files, and it is confirmed that the model which only has one property will grow-up to more properties. So it is not valid to flatten the model. So this flatten feature will not be supported in DPG. @m-nash will confirm this.

Move it to Backlog and wait for the final conclusion.