Skip to content

Commit

Permalink
update api name
Browse files Browse the repository at this point in the history
  • Loading branch information
ArcturusZhang committed Dec 20, 2024
1 parent 0c6d9dd commit f7e5e2a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -842,15 +842,15 @@ private List<MethodBodyStatement> BuildDeserializePropertiesStatements(ScopedApi

if (_additionalBinaryDataProperty != null)
{
var binaryDataDeserializationValue = ClientModelPlugin.Instance.TypeFactory.DeserializeForType(
var binaryDataDeserializationValue = ClientModelPlugin.Instance.TypeFactory.DeserializeJsonValue(
_additionalBinaryDataProperty.Type.ElementType.FrameworkType, jsonProperty.Value(), SerializationFormat.Default);
propertyDeserializationStatements.Add(
_additionalBinaryDataProperty.AsVariableExpression.AsDictionary(_additionalBinaryDataProperty.Type).Add(jsonProperty.Name(), binaryDataDeserializationValue));
}
else if (rawBinaryData != null)
{
var elementType = rawBinaryData.Type.Arguments[1].FrameworkType;
var rawDataDeserializationValue = ClientModelPlugin.Instance.TypeFactory.DeserializeForType(elementType, jsonProperty.Value(), SerializationFormat.Default);
var rawDataDeserializationValue = ClientModelPlugin.Instance.TypeFactory.DeserializeJsonValue(elementType, jsonProperty.Value(), SerializationFormat.Default);
propertyDeserializationStatements.Add(new IfStatement(_isNotEqualToWireConditionSnippet)
{
rawBinaryData.AsVariableExpression.AsDictionary(rawBinaryData.Type).Add(jsonProperty.Name(), rawDataDeserializationValue)
Expand Down Expand Up @@ -1267,11 +1267,11 @@ private ValueExpression CreateDeserializeValueExpression(CSharpType valueType, S
valueType switch
{
{ IsFrameworkType: true } when valueType.FrameworkType == typeof(Nullable<>) =>
ClientModelPlugin.Instance.TypeFactory.DeserializeForType(valueType.Arguments[0].FrameworkType, jsonElement, serializationFormat),
ClientModelPlugin.Instance.TypeFactory.DeserializeJsonValue(valueType.Arguments[0].FrameworkType, jsonElement, serializationFormat),
{ IsFrameworkType: true } =>
ClientModelPlugin.Instance.TypeFactory.DeserializeForType(valueType.FrameworkType, jsonElement, serializationFormat),
ClientModelPlugin.Instance.TypeFactory.DeserializeJsonValue(valueType.FrameworkType, jsonElement, serializationFormat),
{ IsEnum: true } =>
valueType.ToEnum(ClientModelPlugin.Instance.TypeFactory.DeserializeForType(valueType.UnderlyingEnumType!, jsonElement, serializationFormat)),
valueType.ToEnum(ClientModelPlugin.Instance.TypeFactory.DeserializeJsonValue(valueType.UnderlyingEnumType!, jsonElement, serializationFormat)),
_ => valueType.Deserialize(jsonElement, _mrwOptionsParameterSnippet)
};

Expand Down Expand Up @@ -1589,7 +1589,7 @@ private MethodBodyStatement CreateValueSerializationStatement(

// now we just need to focus on how we serialize a value
if (type.IsFrameworkType)
return ClientModelPlugin.Instance.TypeFactory.SerializeForType(type.FrameworkType, value, _utf8JsonWriterSnippet, _mrwOptionsParameterSnippet, serializationFormat);
return ClientModelPlugin.Instance.TypeFactory.SerializeJsonValue(type.FrameworkType, value, _utf8JsonWriterSnippet, _mrwOptionsParameterSnippet, serializationFormat);

if (!type.IsEnum)
return _utf8JsonWriterSnippet.WriteObjectValue(value.As(type), options: _mrwOptionsParameterSnippet);
Expand All @@ -1614,7 +1614,7 @@ private MethodBodyStatement CreateValueSerializationStatement(
}
}

internal static MethodBodyStatement SerializeValueTypeCore(
internal static MethodBodyStatement SerializeJsonValueCore(
Type valueType,
ValueExpression value,
ScopedApi<Utf8JsonWriter> utf8JsonWriter,
Expand Down Expand Up @@ -1651,7 +1651,7 @@ var t when ValueTypeIsNumber(t) =>
};
}

internal static ValueExpression DeserializeForTypeCore(
internal static ValueExpression DeserializeJsonValueCore(
Type valueType,
ScopedApi<JsonElement> element,
SerializationFormat format)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ public ClientProvider CreateClient(InputClient inputClient)
return methods;
}

public virtual ValueExpression DeserializeForType(Type valueType, ScopedApi<JsonElement> element, SerializationFormat format)
=> MrwSerializationTypeDefinition.DeserializeForTypeCore(valueType, element, format);
public virtual ValueExpression DeserializeJsonValue(Type valueType, ScopedApi<JsonElement> element, SerializationFormat format)
=> MrwSerializationTypeDefinition.DeserializeJsonValueCore(valueType, element, format);

public virtual MethodBodyStatement SerializeForType(
public virtual MethodBodyStatement SerializeJsonValue(
Type valueType,
ValueExpression value,
ScopedApi<Utf8JsonWriter> utf8JsonWriter,
ScopedApi<ModelReaderWriterOptions> mrwOptionsParameter,
SerializationFormat serializationFormat)
=> MrwSerializationTypeDefinition.SerializeValueTypeCore(valueType, value, utf8JsonWriter, mrwOptionsParameter, serializationFormat);
=> MrwSerializationTypeDefinition.SerializeJsonValueCore(valueType, value, utf8JsonWriter, mrwOptionsParameter, serializationFormat);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ public void TestIntSerializationStatement(
[TestCase(typeof(sbyte), SerializationFormat.Default, ExpectedResult = "foo.GetSByte()")]
public string TestIntDeserializeExpression(Type type, SerializationFormat format)
{
var expr = MrwSerializationTypeDefinition.DeserializeForTypeCore(type, new ScopedApi<JsonElement>(new VariableExpression(typeof(JsonElement), "foo")), format);
var expr = MrwSerializationTypeDefinition.DeserializeJsonValueCore(type, new ScopedApi<JsonElement>(new VariableExpression(typeof(JsonElement), "foo")), format);
return expr.ToDisplayString();
}

Expand Down

0 comments on commit f7e5e2a

Please sign in to comment.