Open samvaity opened 3 weeks ago
Want to add in some historical context around this area from the azure-core
libraries.
This concepts already exists in azure-core
libraries but we changed code generation a few years ago to prefer direct usage of ResponseBase<HeaderType, BodyType>
instead as the Response<T>
extension type is owned by the downstream library. This forces the downstream library to add opens to com.azure.core
as azure-core
manages deserialization and creation of responses. So, this was transitioned to prefering ResponseBase<HeaderType, BodyType>
as azure-core
owns that type and doesn't need to use reflection to create an instance of it, though it still needs reflection access for the HeaderType
and BodyType
(but always helps to remove some usage of reflection).
I know one plan of clientcore
is moving the deserialization logic into the library itself rather than clientcore
, so this isn't as much a concern, just wanted to share historical context in this area.
One other minor reason we moved to ResponseBase<H, B>
was to shrink the number of classes in libraries. Some had dozens of custom types.
ACR v2 generation that has a use case for
ReponseWithTypedHeader
concept. https://github.com/srnagar/acr-core-v2Design appraoch:
Add support for custom classes:
ContainerRegistriesCreateManifestResponse
holds HttpStatus and the custom header classContainerRegistriesCreateManifestHeaders
.ContainerRegistriesCreateManifestHeaders
provides strongly typed access to specific headers, which we extract from the HttpHeaders passed in the response.Add support for a typed header class in HttpRequestInformation with
returnHeaderType
propertyPros:
Example update for ACR: