Azure / autorest.csharp

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

[LLC] [Feature] Generate model types that customers can copy to their projects #1522

Open annelo-msft opened 3 years ago

annelo-msft commented 3 years ago

Models are a part of LLC RC1.1.

annelo-msft commented 3 years ago

Additionally, we should think about how to make "convenience layer" updates to models to improve the API, but maintain fidelity with what's in the swagger file. One idea is to add swagger transforms to achieve this. But would we want something like "generated models" with C# transforms on top of them, the way we have in HLC?

annelo-msft commented 3 years ago

Per @christothes:

I wonder if there should be an autorest.md transform that we can add to light up individual models as they come into the grow up story

annelo-msft commented 3 years ago

Consider renaming this issue "story for hand-written models", e.g.

In order to create the OutModel for this PR, I ran the autorest (HLC) generator. I'd like to make a few small changes to it to make it more "track 2 ish", notes on that here: https://apiview.dev/Assemblies/Review/89bac638188c43dc99cc2f82779ef006#Azure.Analytics.Synapse.AccessControl.RoleAssignmentDetails

In the short term, we can achieve this with autorest transforms and using the HLC generator. Longer term, it will be good for us to think about whether we want to maintain the HLC concept of "C# transforms" - the ones we make in partial classes over autorest generated models in HLC.

Since there is no concept of "generated model" in this new world (i.e. LLC models are "hand-written"), it'd be easy to hand-write the whole model and lose fidelity with the swagger file. In my experience, losing fidelity with the swagger file creates a lot of confusion and extra work trying to figure out what the SDK is doing compared to the service.

We could probably have a configuration switch for the generator that tells it which models to generate, and make them internal. The "making them hand-written" story would have us adding a partial class to make a generated type public, and you could do any needed changes in that layer.