Skip to content

[Azure Mgmt Generator] We should have a map/cache to store the corresponding resource type from a resource data #51435

@ArcturusZhang

Description

@ArcturusZhang

In our generated code, there is a requirement that if a method is returning a "resource data", we should wrap it into its corresponding resource type.

For instance, when we have a resource of "VirtualMachine", we should have a triplet - VirtualMachineData (the model), VirtualMachineResource (the resource) and VirtualMachineCollection (the collection). The collection is optional when the resource is a singleton resource.
When a method is documented to return the VirtualMachineData model in its spec, we will generate that method and wrap its return type into VirtualMachineResource instead.

In our current ResourceOperationMethodProvider, there is a logic doing the above:

_serviceMethod.GetOperationMethodReturnType(_isAsync, _resource.Type, _resource.ResourceData.Type),

But this is doing it in a very cumbersome way.

This method is about to return a type, and we should be able to know if this type is a resource data, and if it is, we should be able to know its corresponding resource.
Therefore we should be able to remove this _resource and change this into some kind of querying from our ManagementOutputLibrary.

I think this would simplify the logic a lot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    CodeGenIssues that relate to code generationMgmtThis issue is related to a management package.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions