-
Notifications
You must be signed in to change notification settings - Fork 5k
Description
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:
Line 116 in 2fb4ce9
_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.