format-by-name-rules
does not set the deserialization format string for datetime
#3090
Labels
Mgmt
This issue is related to a management-plane library.
In
OperationalInsights
, using below config:Actual behavior:
The generated deserialization code will use:
lastSkuUpdate = property.Value.GetDateTimeOffset();
This calls the
JsonElement.GetDateTimeOffset()
method that only supports ISO 8601 format.This caused issue: Azure/azure-sdk-for-net#33536
Expected behavior:
The generated code should have a datetime format string:
lastSkuUpdate = property.Value.GetDateTimeOffset("O");
This calls an extension method:
autorest.csharp/src/assets/Generator.Shared/JsonElementExtensions.cs
Lines 66 to 71 in c8280c0
It treats the
JsonElement
as Int64 (Unix Timestamp) or string and the string case can support multiple formats despite the "O" format (ISO8601
) being passed in.autorest.csharp/src/assets/Generator.Shared/TypeFormatters.cs
Lines 125 to 132 in c8280c0
The text was updated successfully, but these errors were encountered: