Open pshao25 opened 11 months ago
How will this work once azure-sdk-for-net starts consuming the new version of BinaryData with MediaType property?
How will this work once azure-sdk-for-net starts consuming the new version of BinaryData with MediaType property?
@JoshLove-msft Thank you for the information! Could you help me understand how this new property is expected to be used? What is the expected value for this property?
how to model bytes: https://github.com/microsoft/typespec/issues/2703
Given a content type/accept, we need some logic like https://github.com/Azure/autorest.csharp/issues/3056#issuecomment-1429403557 to category the content type/accept into one of
Binary
,Form
,Json
,Multipart
,Text
,Xml
. I think this logic should be at somewhere in TCGC.In this issue, we just discuss
Binary
,Json
,Text
when there is only one content type/accept, with body type model, bytes, primitive type.Media type: Json, body type: model
Media type: Json, body type: primitive type (string, int, double, etc)
Actual:
RequestContentHelper.FromObject(body);
Expected: payload is expected, but there is boxing operation, we will optimize at https://github.com/Azure/autorest.csharp/issues/3915Actual:
response.Content.ToObjectFromJson<string>()
Media type: Json, body type: bytes
Actual:
RequestContentHelper.FromObject(body);
Expected: same as above with boxing operationActual:
response.Content
Expected:response.Content.ToObjectFromJson<BinaryData>()
Media type: Binary, body type: model
Media type: Binary, body type: primitive type (string, int, double, etc)
Actual:
RequestContentHelper.FromObject(body);
Expected:BinaryData.FromString(body)
(only applicable to string)Actual:
response.Content.ToObjectFromJson<string>()
Expected:response.Content
Media type: Binary, body type: bytes
Customer issue: https://github.com/Azure/autorest.csharp/issues/3793 Actual:
RequestContentHelper.FromObject(body);
Expected:body
Customer issue: https://github.com/Azure/autorest.csharp/issues/3963 Actual:
response.Content
Media type: Text, body type: model
Media type: Text, body type: primitive type (string, int, double, etc)
Actual:
RequestContentHelper.FromObject(body)
Expected:RequestContent.Create(body)
Customer issue: https://github.com/Azure/autorest.csharp/issues/3816 Actual:
response.Content.ToObjectFromJson<string>()
Expected:response.Content.ToString()
(only applicable to string)Media type: Text, body type: bytes
Actual:
RequestContentHelper.FromObject(body)
Expected: ??Actual:
response.Content
Expected: ??Multiple content types
Case 1: content types come to same media type
Both of the content type "application/octet-stream" and "image/jpeg" go to the media type Byte. So the conversion of body is the same as single content type. (but a new parameter content type will be added to method)
Case 2: content types come to different media types
Solution 1:
Solution 2:
Solution 3:
Solution 4: