Add serialization model and unify all generator code in one place (#371)

This commit is contained in:
Pavel Krymets 2019-12-23 09:31:39 -08:00 коммит произвёл GitHub
Родитель ce0d63484f
Коммит 3cd5465b41
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
86 изменённых файлов: 677 добавлений и 511 удалений

Просмотреть файл

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using AutoRest.CSharp.V3.ClientModels.Serialization;
using AutoRest.CSharp.V3.Pipeline;
using AutoRest.CSharp.V3.Pipeline.Generated;
using AutoRest.CSharp.V3.Plugins;
@ -55,7 +56,7 @@ namespace AutoRest.CSharp.V3.ClientModels
switch (requestParameter.Schema)
{
case ConstantSchema constant:
constantOrParameter = ClientModelBuilderHelpers.ParseClientConstant(constant.Value.Value, ClientModelBuilderHelpers.CreateType(constant.ValueType, constant.Value.Value == null));
constantOrParameter = ClientModelBuilderHelpers.ParseClientConstant(constant);
valueSchema = constant.ValueType;
break;
case BinarySchema _:
@ -97,7 +98,7 @@ namespace AutoRest.CSharp.V3.ClientModels
pathParameters.Add(serializedName, new PathSegment(constantOrParameter.Value, true, serializationFormat));
break;
case ParameterLocation.Body when constantOrParameter is ConstantOrParameter constantOrParameterValue:
body = new RequestBody(constantOrParameterValue, serializationFormat);
body = new RequestBody(constantOrParameterValue, ClientModelBuilderHelpers.CreateSerialization(requestParameter.Schema, requestParameter.IsNullable()));
break;
case ParameterLocation.Uri:
uriParameters[defaultName] = constantOrParameter.Value;
@ -130,7 +131,7 @@ namespace AutoRest.CSharp.V3.ClientModels
{
var schema = schemaResponse.Schema is ConstantSchema constantSchema ? constantSchema.ValueType : schemaResponse.Schema;
var responseType = ClientModelBuilderHelpers.CreateType(schema, isNullable: false);
responseBody = new ResponseBody(responseType, ClientModelBuilderHelpers.GetSerializationFormat(schema));
responseBody = new ResponseBody(responseType, ClientModelBuilderHelpers.CreateSerialization(schema, false));
}
ClientMethodResponse clientResponse = new ClientMethodResponse(

Просмотреть файл

@ -3,6 +3,7 @@
using System;
using System.Globalization;
using AutoRest.CSharp.V3.ClientModels.Serialization;
using AutoRest.CSharp.V3.Pipeline.Generated;
namespace AutoRest.CSharp.V3.ClientModels
@ -13,6 +14,7 @@ namespace AutoRest.CSharp.V3.ClientModels
public static ClientTypeReference CreateType(Schema schema, bool isNullable) => schema switch
{
ConstantSchema constantSchema => CreateType(constantSchema.ValueType, isNullable),
BinarySchema _ => (ClientTypeReference)new BinaryTypeReference(isNullable),
ByteArraySchema _ => new BinaryTypeReference(isNullable),
//https://devblogs.microsoft.com/dotnet/do-more-with-patterns-in-c-8-0/
@ -83,5 +85,31 @@ namespace AutoRest.CSharp.V3.ClientModels
}
};
public static ClientConstant ParseClientConstant(ConstantSchema constant)
{
return ParseClientConstant(constant.Value.Value, CreateType(constant.ValueType, constant.Value.Value == null));
}
public static JsonSerialization CreateSerialization(Schema schema, bool isNullable)
{
switch (schema)
{
case ConstantSchema constantSchema:
return CreateSerialization(constantSchema.ValueType, constantSchema.Value.Value == null);
case ArraySchema arraySchema:
return new JsonArraySerialization(CreateType(arraySchema, false), CreateSerialization(arraySchema.ElementType, false));
case DictionarySchema dictionarySchema:
var dictionaryElementTypeReference = new DictionaryTypeReference(
new FrameworkTypeReference(typeof(string)),
CreateType(dictionarySchema.ElementType, false),
false);
return new JsonObjectSerialization(dictionaryElementTypeReference, Array.Empty<JsonPropertySerialization>(),
new JsonDynamicPropertiesSerialization(CreateSerialization(dictionarySchema.ElementType, false)));
default:
return new JsonValueSerialization(CreateType(schema, isNullable), GetSerializationFormat(schema));
}
}
}
}

Просмотреть файл

@ -2,25 +2,28 @@
// Licensed under the MIT License. See License.txt in the project root for license information.
using System.Collections.Generic;
using AutoRest.CSharp.V3.ClientModels.Serialization;
using AutoRest.CSharp.V3.Pipeline.Generated;
namespace AutoRest.CSharp.V3.ClientModels
{
internal class ClientObject : ClientModel, ISchemaTypeProvider
{
public ClientObject(Schema schema, string name, SchemaTypeReference? inherits, IEnumerable<ClientObjectProperty> properties, ClientObjectDiscriminator? discriminator, DictionaryTypeReference? implementsDictionary)
public ClientObject(Schema schema, string name, SchemaTypeReference? inherits, IEnumerable<ClientObjectProperty> properties, ClientObjectDiscriminator? discriminator, DictionaryTypeReference? implementsDictionary, JsonObjectSerialization serialization)
{
Schema = schema;
Name = name;
Inherits = inherits;
Discriminator = discriminator;
ImplementsDictionary = implementsDictionary;
Serialization = serialization;
Properties = new List<ClientObjectProperty>(properties);
}
public override string Name { get; }
public Schema Schema { get; }
public SchemaTypeReference? Inherits { get; }
public JsonObjectSerialization Serialization { get; }
public IList<ClientObjectProperty> Properties { get; }
public ClientObjectDiscriminator? Discriminator { get; }
public DictionaryTypeReference? ImplementsDictionary { get; }

Просмотреть файл

@ -24,6 +24,5 @@ namespace AutoRest.CSharp.V3.ClientModels
}
public bool HasDescendants => Implementations.Any();
public bool HasDirectDescendants => Implementations.Any(i => i.IsDirect);
}
}

Просмотреть файл

@ -5,14 +5,11 @@ namespace AutoRest.CSharp.V3.ClientModels
{
internal class ClientObjectProperty
{
public ClientObjectProperty(string name, ClientTypeReference type, bool isReadOnly, string serializedName,
SerializationFormat format = SerializationFormat.Default, ClientConstant? defaultValue = null)
public ClientObjectProperty(string name, ClientTypeReference type, bool isReadOnly, ClientConstant? defaultValue = null)
{
Name = name;
Type = type;
IsReadOnly = isReadOnly;
SerializedName = serializedName;
Format = format;
DefaultValue = defaultValue;
}
@ -20,7 +17,5 @@ namespace AutoRest.CSharp.V3.ClientModels
public ClientConstant? DefaultValue { get; }
public ClientTypeReference Type { get; }
public bool IsReadOnly { get; }
public string SerializedName { get; set; }
public SerializationFormat Format { get; }
}
}
}

Просмотреть файл

@ -2,11 +2,14 @@
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using AutoRest.CSharp.V3.ClientModels.Serialization;
using AutoRest.CSharp.V3.Pipeline.Generated;
using AutoRest.CSharp.V3.Plugins;
using Microsoft.VisualBasic;
namespace AutoRest.CSharp.V3.ClientModels
{
@ -26,7 +29,7 @@ namespace AutoRest.CSharp.V3.ClientModels
private static ClientModel BuildClientObject(ObjectSchema objectSchema)
{
ClientTypeReference? inheritsFromTypeReference = null;
DictionaryTypeReference? dictionaryElementTypeReference = null;
DictionarySchema? inheritedDictionarySchema = null;
foreach (ComplexSchema complexSchema in objectSchema.Parents!.Immediate)
{
@ -36,21 +39,26 @@ namespace AutoRest.CSharp.V3.ClientModels
inheritsFromTypeReference = ClientModelBuilderHelpers.CreateType(parentObjectSchema, false);
break;
case DictionarySchema dictionarySchema:
var dictionaryElementType = dictionarySchema.ElementType;
dictionaryElementTypeReference = new DictionaryTypeReference(
new FrameworkTypeReference(typeof(string)),
ClientModelBuilderHelpers.CreateType(dictionaryElementType, false),
false);
inheritedDictionarySchema = dictionarySchema;
break;
}
}
List<ClientObjectProperty> properties = new List<ClientObjectProperty>();
List<JsonPropertySerialization> serializationProperties = new List<JsonPropertySerialization>();
foreach (Property property in objectSchema.Properties!)
{
properties.Add(CreateProperty(property));
ClientObjectProperty clientObjectProperty = CreateProperty(property);
properties.Add(clientObjectProperty);
}
foreach (var schema in EnumerateHierarchy(objectSchema))
{
foreach (Property property in schema.Properties!)
{
serializationProperties.Add(CreateSerialization(property));
}
}
Discriminator? schemaDiscriminator = objectSchema.Discriminator;
@ -79,13 +87,60 @@ namespace AutoRest.CSharp.V3.ClientModels
);
}
var schemaTypeReference = ClientModelBuilderHelpers.CreateType(objectSchema, false);
return new ClientObject(
objectSchema,
objectSchema.CSharpName(),
(SchemaTypeReference?) inheritsFromTypeReference,
properties.ToArray(),
discriminator,
dictionaryElementTypeReference
inheritedDictionarySchema == null ? null : CreateDictionaryType(inheritedDictionarySchema),
new JsonObjectSerialization(schemaTypeReference, serializationProperties.ToArray(), CreateAdditionalProperties(objectSchema))
);
}
private static JsonDynamicPropertiesSerialization? CreateAdditionalProperties(ObjectSchema objectSchema)
{
var inheritedDictionarySchema = objectSchema.Parents!.All.OfType<DictionarySchema>().FirstOrDefault();
if (inheritedDictionarySchema == null)
{
return null;
}
return new JsonDynamicPropertiesSerialization(
ClientModelBuilderHelpers.CreateSerialization(inheritedDictionarySchema.ElementType, false)
);
}
private static DictionaryTypeReference CreateDictionaryType(DictionarySchema inheritedDictionarySchema)
{
return new DictionaryTypeReference(
new FrameworkTypeReference(typeof(string)),
ClientModelBuilderHelpers.CreateType(inheritedDictionarySchema.ElementType, false),
false);
}
private static IEnumerable<ObjectSchema> EnumerateHierarchy(ObjectSchema schema)
{
yield return schema;
foreach (ComplexSchema parent in schema.Parents!.All)
{
if (parent is ObjectSchema objectSchema)
{
yield return objectSchema;
}
}
}
private static JsonPropertySerialization CreateSerialization(Property property)
{
return new JsonPropertySerialization(
property.SerializedName,
property.CSharpName(),
ClientModelBuilderHelpers.CreateSerialization(property.Schema, property.IsNullable()),
ClientModelBuilderHelpers.CreateType(property.Schema, property.IsNullable())
);
}
@ -130,8 +185,6 @@ namespace AutoRest.CSharp.V3.ClientModels
return new ClientObjectProperty(property.CSharpName(),
type,
isReadOnly,
property.SerializedName,
ClientModelBuilderHelpers.GetSerializationFormat(property.Schema),
defaultValue);
}
}

Просмотреть файл

@ -1,17 +1,19 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using AutoRest.CSharp.V3.ClientModels.Serialization;
namespace AutoRest.CSharp.V3.ClientModels
{
internal class RequestBody
{
public ConstantOrParameter Value { get; }
public SerializationFormat Format { get; }
public JsonSerialization Serialization { get; }
public RequestBody(ConstantOrParameter value, SerializationFormat format = SerializationFormat.Default)
public RequestBody(ConstantOrParameter value, JsonSerialization serialization)
{
Value = value;
Format = format;
Serialization = serialization;
}
}
}

Просмотреть файл

@ -1,17 +1,19 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using AutoRest.CSharp.V3.ClientModels.Serialization;
namespace AutoRest.CSharp.V3.ClientModels
{
internal class ResponseBody
{
public ClientTypeReference Value { get; }
public SerializationFormat Format { get; }
public ResponseBody(ClientTypeReference value, SerializationFormat format = SerializationFormat.Default)
public ResponseBody(ClientTypeReference value, JsonSerialization serialization)
{
Serialization = serialization;
Value = value;
Format = format;
}
public JsonSerialization Serialization { get; }
public ClientTypeReference Value { get; }
}
}

Просмотреть файл

@ -0,0 +1,17 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
namespace AutoRest.CSharp.V3.ClientModels.Serialization
{
internal class JsonArraySerialization: JsonSerialization
{
public JsonArraySerialization(ClientTypeReference type, JsonSerialization valueSerialization)
{
Type = type;
ValueSerialization = valueSerialization;
}
public override ClientTypeReference Type { get; }
public JsonSerialization ValueSerialization { get; }
}
}

Просмотреть файл

@ -0,0 +1,15 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
namespace AutoRest.CSharp.V3.ClientModels.Serialization
{
internal class JsonDynamicPropertiesSerialization
{
public JsonDynamicPropertiesSerialization(JsonSerialization valueSerialization)
{
ValueSerialization = valueSerialization;
}
public JsonSerialization ValueSerialization { get; }
}
}

Просмотреть файл

@ -0,0 +1,19 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
namespace AutoRest.CSharp.V3.ClientModels.Serialization
{
internal class JsonObjectSerialization: JsonSerialization
{
public JsonObjectSerialization(ClientTypeReference type, JsonPropertySerialization[] properties, JsonDynamicPropertiesSerialization? additionalProperties)
{
Type = type;
Properties = properties;
AdditionalProperties = additionalProperties;
}
public override ClientTypeReference Type { get; }
public JsonPropertySerialization[] Properties { get; }
public JsonDynamicPropertiesSerialization? AdditionalProperties { get; }
}
}

Просмотреть файл

@ -0,0 +1,21 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
namespace AutoRest.CSharp.V3.ClientModels.Serialization
{
internal class JsonPropertySerialization
{
public JsonPropertySerialization(string name, string memberName, JsonSerialization valueSerialization, ClientTypeReference type)
{
Name = name;
MemberName = memberName;
ValueSerialization = valueSerialization;
Type = type;
}
public string Name { get; }
public string MemberName { get; }
public ClientTypeReference Type { get; }
public JsonSerialization ValueSerialization { get; }
}
}

Просмотреть файл

@ -0,0 +1,11 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
namespace AutoRest.CSharp.V3.ClientModels.Serialization
{
internal abstract class JsonSerialization
{
public abstract ClientTypeReference Type { get; }
}
}

Просмотреть файл

@ -0,0 +1,18 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
namespace AutoRest.CSharp.V3.ClientModels.Serialization
{
internal class JsonValueSerialization: JsonSerialization
{
public JsonValueSerialization(ClientTypeReference type, SerializationFormat format)
{
Type = type;
Format = format;
}
public override ClientTypeReference Type { get; }
public SerializationFormat Format { get; }
}
}

Просмотреть файл

@ -8,10 +8,12 @@ using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using AutoRest.CSharp.V3.ClientModels;
using AutoRest.CSharp.V3.ClientModels.Serialization;
using AutoRest.CSharp.V3.Utilities;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using YamlDotNet.Serialization;
using SerializationFormat = AutoRest.CSharp.V3.ClientModels.SerializationFormat;
namespace AutoRest.CSharp.V3.CodeGen
@ -117,8 +119,7 @@ namespace AutoRest.CSharp.V3.CodeGen
ConstantOrParameter value = body.Value;
writer.ToSerializeCall(
value.Type,
body.Format,
body.Serialization,
_typeFactory,
w => WriteConstantOrParameter(w, value),
writerName: w => w.Append($"content.{nameof(Utf8JsonRequestContent.JsonWriter)}"));
@ -223,7 +224,8 @@ namespace AutoRest.CSharp.V3.CodeGen
private CodeWriter.CodeWriterScope? WriteValueNullCheck(CodeWriter writer, ConstantOrParameter value)
{
if (value.IsConstant) return default;
if (value.IsConstant)
return default;
var type = _typeFactory.CreateType(value.Type);
if (type.IsNullable)
@ -298,17 +300,16 @@ namespace AutoRest.CSharp.V3.CodeGen
using (responseBody != null ? writer.Scope() : default)
{
string? valueVariable = null;
string valueVariable = "value";
if (responseBody != null)
{
writer.Line($"using var document = await {writer.Type(typeof(JsonDocument))}.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);");
writer.ToDeserializeCall(
responseBody.Value,
responseBody.Format,
responseBody.Serialization,
_typeFactory,
w => w.Append($"document.RootElement"),
out valueVariable
ref valueVariable
);
}

Просмотреть файл

@ -2,137 +2,158 @@
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Text.Json;
using AutoRest.CSharp.V3.ClientModels;
using AutoRest.CSharp.V3.ClientModels.Serialization;
namespace AutoRest.CSharp.V3.CodeGen
{
internal static class JsonSerializerExtensions
{
public static void ToSerializeCall(this CodeWriter writer, ClientTypeReference type, SerializationFormat format, TypeFactory typeFactory, CodeWriterDelegate name, CodeWriterDelegate? serializedName = null, CodeWriterDelegate? writerName = null)
public static void ToSerializeCall(this CodeWriter writer, JsonSerialization serialization, TypeFactory typeFactory, CodeWriterDelegate name, CodeWriterDelegate? writerName = null)
{
writerName ??= w => w.AppendRaw("writer");
if (serializedName != null)
{
writer.Line($"{writerName}.WritePropertyName({serializedName});");
}
var type = serialization.Type;
CSharpType implementationType = typeFactory.CreateType(type);
switch (type)
switch (serialization)
{
case CollectionTypeReference array:
case JsonArraySerialization array:
writer.Line($"{writerName}.WriteStartArray();");
string collectionItemVariable = writer.GetTemporaryVariable("item");
writer.Line($"foreach (var {collectionItemVariable:D} in {name})");
using (writer.Scope())
{
writer.ToSerializeCall(
array.ItemType,
format,
array.ValueSerialization,
typeFactory,
w => w.AppendRaw(collectionItemVariable),
serializedName: null,
writerName);
}
writer.Line($"{writerName}.WriteEndArray();");
return;
case DictionaryTypeReference dictionary:
case JsonObjectSerialization dictionary:
writer.Line($"{writerName}.WriteStartObject();");
string itemVariable = writer.GetTemporaryVariable("item");
writer.Line($"foreach (var {itemVariable:D} in {name})");
using (writer.Scope())
foreach (JsonPropertySerialization property in dictionary.Properties)
{
writer.ToSerializeCall(
dictionary.ValueType,
format,
typeFactory,
w => w.Append($"{itemVariable}.Value"),
w => w.Append($"{itemVariable}.Key"),
writerName);
using (property.Type.IsNullable ? writer.If($"{property.MemberName} != null") : default)
{
writer.Line($"{writerName}.WritePropertyName({property.Name:L});");
writer.ToSerializeCall(
property.ValueSerialization,
typeFactory,
w => w.Append($"{property.MemberName}"));
}
}
if (dictionary.AdditionalProperties != null)
{
writer.Line($"foreach (var {itemVariable:D} in {name})");
using (writer.Scope())
{
writer.Line($"{writerName}.WritePropertyName({itemVariable}.Key);");
writer.ToSerializeCall(
dictionary.AdditionalProperties.ValueSerialization,
typeFactory,
w => w.Append($"{itemVariable}.Value"),
writerName);
}
}
writer.Line($"{writerName}.WriteEndObject();");
return;
case SchemaTypeReference schemaTypeReference:
switch (typeFactory.ResolveReference(schemaTypeReference))
case JsonValueSerialization valueSerialization:
switch (valueSerialization.Type)
{
case ClientObject _:
writer.Line($"{writerName}.WriteObjectValue({name});");
case SchemaTypeReference schemaTypeReference:
switch (typeFactory.ResolveReference(schemaTypeReference))
{
case ClientObject _:
writer.Line($"{writerName}.WriteObjectValue({name});");
return;
case ClientEnum clientEnum:
writer.Append($"{writerName}.WriteStringValue({name}")
.AppendNullableValue(implementationType)
.AppendRaw(clientEnum.IsStringBased ? ".ToString()" : ".ToSerialString()")
.Line($");");
return;
}
return;
case ClientEnum clientEnum:
writer.Append($"{writerName}.WriteStringValue({name}")
.AppendNullableValue(implementationType)
.AppendRaw(clientEnum.IsStringBased ? ".ToString()" : ".ToSerialString()")
.Line($");");
case BinaryTypeReference _:
writer.Line($"{writerName}.WriteBase64StringValue({name});");
return;
}
return;
case BinaryTypeReference _:
writer.Line($"{writerName}.WriteBase64StringValue({name});");
return;
case FrameworkTypeReference frameworkTypeReference:
var frameworkType = frameworkTypeReference.Type;
bool writeFormat = false;
case FrameworkTypeReference frameworkTypeReference:
var frameworkType = frameworkTypeReference.Type;
bool writeFormat = false;
writer.Append($"{writerName}.");
if (frameworkType == typeof(decimal) ||
frameworkType == typeof(double) ||
frameworkType == typeof(float) ||
frameworkType == typeof(long) ||
frameworkType == typeof(int) ||
frameworkType == typeof(short))
{
writer.AppendRaw("WriteNumberValue");
}
else if (frameworkType == typeof(object))
{
writer.AppendRaw("WriteObjectValue");
}
else if (frameworkType == typeof(string) ||
frameworkType == typeof(char))
{
writer.AppendRaw("WriteStringValue");
}
else if (frameworkType == typeof(bool))
{
writer.AppendRaw("WriteBooleanValue");
}
else if (frameworkType == typeof(DateTimeOffset) ||
frameworkType == typeof(DateTime) ||
frameworkType == typeof(TimeSpan))
{
writer.AppendRaw("WriteStringValue");
writeFormat = true;
}
writer.Append($"{writerName}.");
if (frameworkType == typeof(decimal) ||
frameworkType == typeof(double) ||
frameworkType == typeof(float) ||
frameworkType == typeof(long) ||
frameworkType == typeof(int) ||
frameworkType == typeof(short))
{
writer.AppendRaw("WriteNumberValue");
}
else if (frameworkType == typeof(object))
{
writer.AppendRaw("WriteObjectValue");
}
else if (frameworkType == typeof(string) ||
frameworkType == typeof(char))
{
writer.AppendRaw("WriteStringValue");
}
else if (frameworkType == typeof(bool))
{
writer.AppendRaw("WriteBooleanValue");
}
else if (frameworkType == typeof(DateTimeOffset) ||
frameworkType == typeof(DateTime) ||
frameworkType == typeof(TimeSpan))
{
writer.AppendRaw("WriteStringValue");
writeFormat = true;
}
writer.Append($"({name}")
.AppendNullableValue(implementationType);
writer.Append($"({name}")
.AppendNullableValue(implementationType);
if (writeFormat && valueSerialization.Format.ToFormatSpecifier() is string formatString)
{
writer.Append($", {formatString:L}");
}
if (writeFormat && format.ToFormatSpecifier() is string formatString)
{
writer.Append($", {formatString:L}");
writer.LineRaw(");");
return;
default:
throw new NotSupportedException();
}
writer.LineRaw(");");
return;
default:
throw new NotSupportedException();
}
}
public static void ToDeserializeCall(this CodeWriter writer, ClientTypeReference type, SerializationFormat format, TypeFactory typeFactory, CodeWriterDelegate element, out string destination)
public static void ToDeserializeCall(this CodeWriter writer, JsonSerialization serialization, TypeFactory typeFactory, CodeWriterDelegate element, ref string destination)
{
destination = writer.GetTemporaryVariable("value");
var type = serialization.Type;
if (CanDeserializeAsExpression(type))
destination = writer.GetTemporaryVariable(destination);
if (serialization is JsonValueSerialization valueSerialization)
{
writer.Append($"var {destination:D} =")
.ToDeserializeCall(type, format, typeFactory, element);
.ToDeserializeCall(valueSerialization, typeFactory, element);
writer.LineRaw(";");
}
else
@ -141,105 +162,131 @@ namespace AutoRest.CSharp.V3.CodeGen
writer
.Line($"{typeFactory.CreateType(type)} {destination:D} = new {typeFactory.CreateConcreteType(type)}();")
.ToDeserializeCall(type, format, typeFactory, w=>w.AppendRaw(s), element);
.ToDeserializeCall(serialization, typeFactory, w => w.AppendRaw(s), element);
}
}
private static bool CanDeserializeAsExpression(ClientTypeReference type)
public static void ToDeserializeCall(this CodeWriter writer, JsonSerialization serialization, TypeFactory typeFactory, CodeWriterDelegate destination, CodeWriterDelegate element)
{
return !(type is CollectionTypeReference || type is DictionaryTypeReference);
}
public static void ToDeserializeCall(this CodeWriter writer, ClientTypeReference type, SerializationFormat format, TypeFactory typeFactory, CodeWriterDelegate destination, CodeWriterDelegate element)
{
switch (type)
switch (serialization)
{
case CollectionTypeReference array:
case JsonArraySerialization array:
string collectionItemVariable = writer.GetTemporaryVariable("item");
writer.Line($"foreach (var {collectionItemVariable:D} in {element}.EnumerateArray())");
using (writer.Scope())
{
if (CanDeserializeAsExpression(array.ItemType))
if (array.ValueSerialization is JsonValueSerialization valueSerialization)
{
writer.Append($"{destination}.Add(");
writer.ToDeserializeCall(
array.ItemType,
format,
valueSerialization,
typeFactory,
w => w.AppendRaw(collectionItemVariable));
writer.Line($");");
}
else
{
var itemVariableName = "value";
writer.ToDeserializeCall(
array.ItemType,
format,
array.ValueSerialization,
typeFactory,
w => w.AppendRaw(collectionItemVariable),
out var temp);
ref itemVariableName);
writer.Append($"{destination}.Add({temp});");
writer.Append($"{destination}.Add({itemVariableName});");
}
}
return;
case DictionaryTypeReference dictionary:
string itemVariable = writer.GetTemporaryVariable("item");
case JsonObjectSerialization dictionary:
string itemVariable = writer.GetTemporaryVariable("property");
writer.Line($"foreach (var {itemVariable:D} in {element}.EnumerateObject())");
using (writer.Scope())
{
if (CanDeserializeAsExpression(dictionary.ValueType))
foreach (JsonPropertySerialization property in dictionary.Properties)
{
writer.Append($"{destination}.Add({itemVariable}.Name, ");
writer.ToDeserializeCall(
dictionary.ValueType,
format,
typeFactory,
w => w.Append($"{itemVariable}.Value"));
writer.Line($");");
ReadProperty(writer, itemVariable, destination, property, typeFactory);
}
else
{
writer.ToDeserializeCall(
dictionary.ValueType,
format,
typeFactory,
w => w.Append($"{itemVariable}.Value"),
out var temp);
writer.Append($"{destination}.Add({itemVariable}.Name, {temp});");
if (dictionary.AdditionalProperties is JsonDynamicPropertiesSerialization additionalProperties)
{
if (additionalProperties.ValueSerialization is JsonValueSerialization valueSerialization)
{
writer.Append($"{destination}.Add({itemVariable}.Name, ");
writer.ToDeserializeCall(
valueSerialization,
typeFactory,
w => w.Append($"{itemVariable}.Value"));
writer.Line($");");
}
else
{
var itemVariableName = "value";
writer.ToDeserializeCall(
additionalProperties.ValueSerialization,
typeFactory,
w => w.Append($"{itemVariable}.Value"),
ref itemVariableName);
writer.Append($"{destination}.Add({itemVariable}.Name, {itemVariableName});");
}
}
}
return;
}
writer.Append($"{destination} = ");
ToDeserializeCall(writer, type, format, typeFactory, element);
ToDeserializeCall(writer, (JsonValueSerialization)serialization, typeFactory, element);
writer.Line($";");
}
public static void ToDeserializeCall(this CodeWriter writer, ClientTypeReference type, SerializationFormat format, TypeFactory typeFactory, CodeWriterDelegate element)
private static void ReadProperty(CodeWriter writer, string itemVariable, CodeWriterDelegate destination, JsonPropertySerialization property, TypeFactory typeFactory)
{
CSharpType cSharpType = typeFactory.CreateType(type).WithNullable(false);
var type = property.Type;
var name = property.MemberName;
switch (type)
CSharpType propertyType = typeFactory.CreateType(type);
void WriteNullCheck()
{
using (writer.If($"{itemVariable}.Value.ValueKind == {writer.Type(typeof(JsonValueKind))}.Null"))
{
writer.Append($"continue;");
}
}
void WriteInitialization()
{
if (propertyType.IsNullable && (type is DictionaryTypeReference || type is CollectionTypeReference))
{
writer.Line($"{destination}.{name} = new {writer.Type(typeFactory.CreateConcreteType(property.Type))}();");
}
}
writer.Append($"if({itemVariable}.NameEquals({property.Name:L}))");
using (writer.Scope())
{
if (propertyType.IsNullable)
{
WriteNullCheck();
}
WriteInitialization();
writer.ToDeserializeCall(property.ValueSerialization, typeFactory, w => w.Append($"{destination}.{name}"), w => w.Append($"{itemVariable}.Value"));
writer.Line($"continue;");
}
}
public static void ToDeserializeCall(this CodeWriter writer, JsonValueSerialization serialization, TypeFactory typeFactory, CodeWriterDelegate element)
{
switch (serialization.Type)
{
case SchemaTypeReference schemaTypeReference:
switch (typeFactory.ResolveReference(schemaTypeReference))
{
case ClientObject _:
writer.Append($"{cSharpType}.Deserialize{cSharpType.Name}({element})");
break;
case ClientEnum clientEnum when clientEnum.IsStringBased:
writer.Append($"new {cSharpType}({element}.GetString())");
break;
case ClientEnum clientEnum when !clientEnum.IsStringBased:
writer.Append($"{element}.GetString().To{cSharpType}()");
break;
}
writer.ToDeserializeCall(schemaTypeReference, typeFactory, element);
return;
case BinaryTypeReference _:
@ -285,7 +332,7 @@ namespace AutoRest.CSharp.V3.CodeGen
writer.AppendRaw("(");
if (includeFormat && format.ToFormatSpecifier() is string formatString)
if (includeFormat && serialization.Format.ToFormatSpecifier() is string formatString)
{
writer.Literal(formatString);
}
@ -295,6 +342,26 @@ namespace AutoRest.CSharp.V3.CodeGen
}
}
public static void ToDeserializeCall(this CodeWriter writer, SchemaTypeReference type, TypeFactory typeFactory, CodeWriterDelegate element)
{
CSharpType cSharpType = typeFactory.CreateType(type).WithNullable(false);
switch (typeFactory.ResolveReference(type))
{
case ClientObject _:
writer.Append($"{cSharpType}.Deserialize{cSharpType.Name}({element})");
break;
case ClientEnum clientEnum when clientEnum.IsStringBased:
writer.Append($"new {cSharpType}({element}.GetString())");
break;
case ClientEnum clientEnum when !clientEnum.IsStringBased:
writer.Append($"{element}.GetString().To{cSharpType}()");
break;
}
}
public static string? ToFormatSpecifier(this SerializationFormat format) => format switch
{
SerializationFormat.DateTime_RFC1123 => "R",

Просмотреть файл

@ -2,12 +2,10 @@
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using AutoRest.CSharp.V3.ClientModels;
using AutoRest.CSharp.V3.Plugins;
using AutoRest.CSharp.V3.Utilities;
using Azure.Core;
namespace AutoRest.CSharp.V3.CodeGen
@ -34,40 +32,6 @@ namespace AutoRest.CSharp.V3.CodeGen
}
}
private void ReadProperty(CodeWriter writer, ClientObjectProperty property)
{
var type = property.Type;
var name = property.Name;
var format = property.Format;
CSharpType propertyType = _typeFactory.CreateType(type);
void WriteNullCheck()
{
using (writer.If($"property.Value.ValueKind == {writer.Type(typeof(JsonValueKind))}.Null"))
{
writer.Append($"continue;");
}
}
void WriteInitialization()
{
if (propertyType.IsNullable && (type is DictionaryTypeReference || type is CollectionTypeReference))
{
writer.Line($"result.{name} = new {writer.Type(_typeFactory.CreateConcreteType(property.Type))}();");
}
}
if (propertyType.IsNullable)
{
WriteNullCheck();
}
WriteInitialization();
writer.ToDeserializeCall(type, format, _typeFactory, w=> w.Append($"result.{name}"), w => w.Append($"property.Value"));
}
//TODO: This is currently input schemas only. Does not handle output-style schemas.
private void WriteObjectSerialization(CodeWriter writer, ClientObject model)
@ -100,59 +64,16 @@ namespace AutoRest.CSharp.V3.CodeGen
{
writer
.Append($"case {implementation.Key:L}: return ")
.ToDeserializeCall(implementation.Type, SerializationFormat.Default, _typeFactory, w => w.Append($"element"));
.ToDeserializeCall(implementation.Type, _typeFactory, w => w.Append($"element"));
writer.Line($";");
}
}
}
}
writer.Line($"var result = new {typeText}();");
using (writer.ForEach("var property in element.EnumerateObject()"))
{
DictionaryTypeReference? implementsDictionary = null;
foreach (ClientObject currentType in WalkInheritance(model))
{
foreach (var property in currentType.Properties)
{
using (writer.If($"property.NameEquals(\"{property.SerializedName}\")"))
{
ReadProperty(writer, property);
writer.Line($"continue;");
}
}
implementsDictionary ??= currentType.ImplementsDictionary;
}
if (implementsDictionary != null)
{
writer.Append($"result.Add(property.Name, ");
writer.ToDeserializeCall(implementsDictionary.ValueType, SerializationFormat.Default, _typeFactory, w => w.Append($"property.Value"));
writer.Line($");");
}
}
writer.Line($"return result;");
}
}
private IEnumerable<ClientObject> WalkInheritance(ClientObject model)
{
var currentType = model;
while (currentType != null)
{
yield return currentType;
if (currentType.Inherits == null)
{
yield break;
}
currentType = (ClientObject)_typeFactory.ResolveReference(currentType.Inherits);
var resultVariable = "result";
writer.ToDeserializeCall(model.Serialization, _typeFactory, w=>w.AppendRaw("element"), ref resultVariable);
writer.Line($"return {resultVariable};");
}
}
@ -161,37 +82,7 @@ namespace AutoRest.CSharp.V3.CodeGen
writer.Append($"void {typeof(IUtf8JsonSerializable)}.{nameof(IUtf8JsonSerializable.Write)}({typeof(Utf8JsonWriter)} writer)");
using (writer.Scope())
{
writer.Line($"writer.WriteStartObject();");
DictionaryTypeReference? implementsDictionary = null;
foreach (ClientObject currentType in WalkInheritance(model))
{
foreach (var property in currentType.Properties)
{
using (property.Type.IsNullable ? writer.If($"{property.Name} != null") : default)
{
writer.ToSerializeCall(
property.Type,
property.Format,
_typeFactory,
w => w.Append($"{property.Name}"),
w => w.Literal(property.SerializedName));
}
implementsDictionary ??= currentType.ImplementsDictionary;
}
}
if (implementsDictionary != null)
{
using (writer.ForEach("var item in this"))
{
writer.ToSerializeCall(implementsDictionary.ValueType, SerializationFormat.Default, _typeFactory, w => w.Append($"item.Value"), w => w.Append($"item.Key"));
}
}
writer.Line($"writer.WriteEndObject();");
writer.ToSerializeCall(model.Serialization, _typeFactory, w => w.AppendRaw("this"));
}
}

Просмотреть файл

@ -47,16 +47,16 @@ namespace Azure.Core
}
}
public static DateTimeOffset GetDateTimeOffset(in this JsonElement element, string format = "S") => format switch
public static DateTimeOffset GetDateTimeOffset(in this JsonElement element, string format) => format switch
{
"D" => element.GetDateTimeOffset(),
"S" => element.GetDateTimeOffset(),
"S" => DateTimeOffset.Parse(element.GetString()),
"R" => DateTimeOffset.Parse(element.GetString()),
"U" => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()),
_ => throw new ArgumentException("Format is not supported", nameof(format))
};
public static TimeSpan GetTimeSpan(in this JsonElement element, string format = "P") => format switch
public static TimeSpan GetTimeSpan(in this JsonElement element, string format) => format switch
{
"P" => XmlConvert.ToTimeSpan(element.GetString()),
_ => throw new ArgumentException("Format is not supported", nameof(format))

Просмотреть файл

@ -9,10 +9,10 @@ namespace Azure.Core
{
internal static class Utf8JsonWriterExtensions
{
public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format = "S") =>
public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) =>
writer.WriteStringValue(TypeFormatters.ToString(value, format));
public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format = "P") =>
public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) =>
writer.WriteStringValue(TypeFormatters.ToString(value, format));
public static void WriteObjectValue(this Utf8JsonWriter writer, IUtf8JsonSerializable value)

Просмотреть файл

@ -170,17 +170,27 @@ namespace AutoRest.TestServer.Tests
});
[Test]
[Ignore("https://github.com/Azure/autorest.csharp/issues/368")]
public Task GetArrayDateTimeRfc1123Valid() => Test(async (host, pipeline) =>
{
var result = await ArrayOperations.GetDateTimeRfc1123ValidAsync(ClientDiagnostics, pipeline, host);
CollectionAssert.AreEqual(new[]
{
DateTimeOffset.Parse("2000-12-01 00:00:01+00:00"),
DateTimeOffset.Parse("1980-01-02 00:11:35+00:00"),
DateTimeOffset.Parse("1492-10-12 10:15:01+00:00"),
}, result.Value);
});
[Test]
[Ignore("https://github.com/Azure/autorest.csharp/issues/368")]
public Task GetArrayDateTimeValid() => Test(async (host, pipeline) =>
{
var result = await ArrayOperations.GetDateTimeValidAsync(ClientDiagnostics, pipeline, host);
CollectionAssert.AreEqual(new[]
{
DateTimeOffset.Parse("2000-12-01 00:00:01+00:00"),
DateTimeOffset.Parse("1980-01-02 00:11:35+00:00"),
DateTimeOffset.Parse("1492-10-12 10:15:01+00:00"),
}, result.Value);
});
[Test]
@ -459,22 +469,28 @@ namespace AutoRest.TestServer.Tests
new[] { new Product() { Integer = 1, String = "2" }, new Product() { Integer = 3, String = "4" }, new Product() { Integer = 5, String = "6" }}, host));
[Test]
[Ignore("https://github.com/Azure/autorest.csharp/issues/368")]
public Task PutArrayDateTimeRfc1123Valid() => TestStatus(async (host, pipeline) => await ArrayOperations.PutDateTimeRfc1123ValidAsync(ClientDiagnostics, pipeline,
new DateTimeOffset[] { }, host));
new[] {
DateTimeOffset.Parse("2000-12-01 00:00:01+00:00"),
DateTimeOffset.Parse("1980-01-02 00:11:35+00:00"),
DateTimeOffset.Parse("1492-10-12 10:15:01+00:00"),
}, host));
[Test]
[Ignore("https://github.com/Azure/autorest.csharp/issues/368")]
public Task PutArrayDateTimeValid() => TestStatus(async (host, pipeline) => await ArrayOperations.PutDateValidAsync(ClientDiagnostics, pipeline,
new DateTimeOffset[] { }, host));
[IgnoreOnTestServer(TestServerVersion.V2, "no match")]
public Task PutArrayDateTimeValid() => TestStatus(async (host, pipeline) => await ArrayOperations.PutDateTimeValidAsync(ClientDiagnostics, pipeline,
new[] {
DateTimeOffset.Parse("2000-12-01 00:00:01+00:00"),
DateTimeOffset.Parse("1980-01-02 00:11:35+00:00"),
DateTimeOffset.Parse("1492-10-12 10:15:01+00:00"),
}, host));
[Test]
[Ignore("https://github.com/Azure/autorest.csharp/issues/368")]
public Task PutArrayDateValid() => TestStatus(async (host, pipeline) => await ArrayOperations.PutDateValidAsync(ClientDiagnostics, pipeline,
new[] {
DateTimeOffset.Parse("2000-12-01"),
DateTimeOffset.Parse("1980-01-02"),
DateTimeOffset.Parse("1492-10-12")
DateTimeOffset.Parse("2000-12-01 00:00:01+00:00"),
DateTimeOffset.Parse("1980-01-02 00:11:35+00:00"),
DateTimeOffset.Parse("1492-10-12 10:15:01+00:00"),
}, host));
[Test]

Просмотреть файл

@ -37,7 +37,7 @@ namespace additionalProperties.Models.V100
}
internal static CatAPTrue DeserializeCatAPTrue(JsonElement element)
{
var result = new CatAPTrue();
CatAPTrue result = new CatAPTrue();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("friendly"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace additionalProperties.Models.V100
}
internal static Error DeserializeError(JsonElement element)
{
var result = new Error();
Error result = new Error();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("status"))

Просмотреть файл

@ -39,7 +39,7 @@ namespace additionalProperties.Models.V100
}
internal static PetAPInProperties DeserializePetAPInProperties(JsonElement element)
{
var result = new PetAPInProperties();
PetAPInProperties result = new PetAPInProperties();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("id"))
@ -72,9 +72,9 @@ namespace additionalProperties.Models.V100
continue;
}
result.AdditionalProperties = new Dictionary<string, float>();
foreach (var item in property.Value.EnumerateObject())
foreach (var property0 in property.Value.EnumerateObject())
{
result.AdditionalProperties.Add(item.Name, item.Value.GetSingle());
result.AdditionalProperties.Add(property0.Name, property0.Value.GetSingle());
}
continue;
}

Просмотреть файл

@ -46,7 +46,7 @@ namespace additionalProperties.Models.V100
}
internal static PetAPInPropertiesWithAPString DeserializePetAPInPropertiesWithAPString(JsonElement element)
{
var result = new PetAPInPropertiesWithAPString();
PetAPInPropertiesWithAPString result = new PetAPInPropertiesWithAPString();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("id"))
@ -84,9 +84,9 @@ namespace additionalProperties.Models.V100
continue;
}
result.AdditionalProperties = new Dictionary<string, float>();
foreach (var item in property.Value.EnumerateObject())
foreach (var property0 in property.Value.EnumerateObject())
{
result.AdditionalProperties.Add(item.Name, item.Value.GetSingle());
result.AdditionalProperties.Add(property0.Name, property0.Value.GetSingle());
}
continue;
}

Просмотреть файл

@ -32,7 +32,7 @@ namespace additionalProperties.Models.V100
}
internal static PetAPObject DeserializePetAPObject(JsonElement element)
{
var result = new PetAPObject();
PetAPObject result = new PetAPObject();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("id"))

Просмотреть файл

@ -32,7 +32,7 @@ namespace additionalProperties.Models.V100
}
internal static PetAPString DeserializePetAPString(JsonElement element)
{
var result = new PetAPString();
PetAPString result = new PetAPString();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("id"))

Просмотреть файл

@ -32,7 +32,7 @@ namespace additionalProperties.Models.V100
}
internal static PetAPTrue DeserializePetAPTrue(JsonElement element)
{
var result = new PetAPTrue();
PetAPTrue result = new PetAPTrue();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("id"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace body_array.Models.V100
}
internal static Error DeserializeError(JsonElement element)
{
var result = new Error();
Error result = new Error();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("status"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace body_array.Models.V100
}
internal static Product DeserializeProduct(JsonElement element)
{
var result = new Product();
Product result = new Product();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("integer"))

Просмотреть файл

@ -1419,7 +1419,7 @@ namespace body_array
ICollection<DateTimeOffset> value = new List<DateTimeOffset>();
foreach (var item in document.RootElement.EnumerateArray())
{
value.Add(item.GetDateTimeOffset());
value.Add(item.GetDateTimeOffset("D"));
}
return Response.FromValue(value, response);
}
@ -1457,7 +1457,7 @@ namespace body_array
content.JsonWriter.WriteStartArray();
foreach (var item in arrayBody)
{
content.JsonWriter.WriteStringValue(item);
content.JsonWriter.WriteStringValue(item, "D");
}
content.JsonWriter.WriteEndArray();
request.Content = content;
@ -1500,7 +1500,7 @@ namespace body_array
ICollection<DateTimeOffset> value = new List<DateTimeOffset>();
foreach (var item in document.RootElement.EnumerateArray())
{
value.Add(item.GetDateTimeOffset());
value.Add(item.GetDateTimeOffset("D"));
}
return Response.FromValue(value, response);
}
@ -1538,7 +1538,7 @@ namespace body_array
ICollection<DateTimeOffset> value = new List<DateTimeOffset>();
foreach (var item in document.RootElement.EnumerateArray())
{
value.Add(item.GetDateTimeOffset());
value.Add(item.GetDateTimeOffset("D"));
}
return Response.FromValue(value, response);
}
@ -1576,7 +1576,7 @@ namespace body_array
ICollection<DateTimeOffset> value = new List<DateTimeOffset>();
foreach (var item in document.RootElement.EnumerateArray())
{
value.Add(item.GetDateTimeOffset());
value.Add(item.GetDateTimeOffset("S"));
}
return Response.FromValue(value, response);
}
@ -1614,7 +1614,7 @@ namespace body_array
content.JsonWriter.WriteStartArray();
foreach (var item in arrayBody)
{
content.JsonWriter.WriteStringValue(item);
content.JsonWriter.WriteStringValue(item, "S");
}
content.JsonWriter.WriteEndArray();
request.Content = content;
@ -1657,7 +1657,7 @@ namespace body_array
ICollection<DateTimeOffset> value = new List<DateTimeOffset>();
foreach (var item in document.RootElement.EnumerateArray())
{
value.Add(item.GetDateTimeOffset());
value.Add(item.GetDateTimeOffset("S"));
}
return Response.FromValue(value, response);
}
@ -1695,7 +1695,7 @@ namespace body_array
ICollection<DateTimeOffset> value = new List<DateTimeOffset>();
foreach (var item in document.RootElement.EnumerateArray())
{
value.Add(item.GetDateTimeOffset());
value.Add(item.GetDateTimeOffset("S"));
}
return Response.FromValue(value, response);
}
@ -1733,7 +1733,7 @@ namespace body_array
ICollection<DateTimeOffset> value = new List<DateTimeOffset>();
foreach (var item in document.RootElement.EnumerateArray())
{
value.Add(item.GetDateTimeOffset());
value.Add(item.GetDateTimeOffset("R"));
}
return Response.FromValue(value, response);
}
@ -1771,7 +1771,7 @@ namespace body_array
content.JsonWriter.WriteStartArray();
foreach (var item in arrayBody)
{
content.JsonWriter.WriteStringValue(item);
content.JsonWriter.WriteStringValue(item, "R");
}
content.JsonWriter.WriteEndArray();
request.Content = content;
@ -1814,7 +1814,7 @@ namespace body_array
ICollection<TimeSpan> value = new List<TimeSpan>();
foreach (var item in document.RootElement.EnumerateArray())
{
value.Add(item.GetTimeSpan());
value.Add(item.GetTimeSpan("P"));
}
return Response.FromValue(value, response);
}
@ -1852,7 +1852,7 @@ namespace body_array
content.JsonWriter.WriteStartArray();
foreach (var item in arrayBody)
{
content.JsonWriter.WriteStringValue(item);
content.JsonWriter.WriteStringValue(item, "P");
}
content.JsonWriter.WriteEndArray();
request.Content = content;
@ -2549,9 +2549,9 @@ namespace body_array
foreach (var item in document.RootElement.EnumerateArray())
{
IDictionary<string, string> value0 = new Dictionary<string, string>();
foreach (var item0 in item.EnumerateObject())
foreach (var property in item.EnumerateObject())
{
value0.Add(item0.Name, item0.Value.GetString());
value0.Add(property.Name, property.Value.GetString());
}
value.Add(value0);
}
@ -2592,9 +2592,9 @@ namespace body_array
foreach (var item in document.RootElement.EnumerateArray())
{
IDictionary<string, string> value0 = new Dictionary<string, string>();
foreach (var item0 in item.EnumerateObject())
foreach (var property in item.EnumerateObject())
{
value0.Add(item0.Name, item0.Value.GetString());
value0.Add(property.Name, property.Value.GetString());
}
value.Add(value0);
}
@ -2635,9 +2635,9 @@ namespace body_array
foreach (var item in document.RootElement.EnumerateArray())
{
IDictionary<string, string> value0 = new Dictionary<string, string>();
foreach (var item0 in item.EnumerateObject())
foreach (var property in item.EnumerateObject())
{
value0.Add(item0.Name, item0.Value.GetString());
value0.Add(property.Name, property.Value.GetString());
}
value.Add(value0);
}
@ -2678,9 +2678,9 @@ namespace body_array
foreach (var item in document.RootElement.EnumerateArray())
{
IDictionary<string, string> value0 = new Dictionary<string, string>();
foreach (var item0 in item.EnumerateObject())
foreach (var property in item.EnumerateObject())
{
value0.Add(item0.Name, item0.Value.GetString());
value0.Add(property.Name, property.Value.GetString());
}
value.Add(value0);
}
@ -2721,9 +2721,9 @@ namespace body_array
foreach (var item in document.RootElement.EnumerateArray())
{
IDictionary<string, string> value0 = new Dictionary<string, string>();
foreach (var item0 in item.EnumerateObject())
foreach (var property in item.EnumerateObject())
{
value0.Add(item0.Name, item0.Value.GetString());
value0.Add(property.Name, property.Value.GetString());
}
value.Add(value0);
}

Просмотреть файл

@ -25,7 +25,7 @@ namespace body_boolean.Models.V100
}
internal static Error DeserializeError(JsonElement element)
{
var result = new Error();
Error result = new Error();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("status"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace body_byte.Models.V100
}
internal static Error DeserializeError(JsonElement element)
{
var result = new Error();
Error result = new Error();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("status"))

Просмотреть файл

@ -26,7 +26,7 @@ namespace body_complex.Models.V20160229
}
internal static ArrayWrapper DeserializeArrayWrapper(JsonElement element)
{
var result = new ArrayWrapper();
ArrayWrapper result = new ArrayWrapper();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("array"))

Просмотреть файл

@ -30,7 +30,7 @@ namespace body_complex.Models.V20160229
}
internal static Basic DeserializeBasic(JsonElement element)
{
var result = new Basic();
Basic result = new Basic();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("id"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace body_complex.Models.V20160229
}
internal static BooleanWrapper DeserializeBooleanWrapper(JsonElement element)
{
var result = new BooleanWrapper();
BooleanWrapper result = new BooleanWrapper();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("field_true"))

Просмотреть файл

@ -20,7 +20,7 @@ namespace body_complex.Models.V20160229
}
internal static ByteWrapper DeserializeByteWrapper(JsonElement element)
{
var result = new ByteWrapper();
ByteWrapper result = new ByteWrapper();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("field"))

Просмотреть файл

@ -41,7 +41,7 @@ namespace body_complex.Models.V20160229
}
internal static Cat DeserializeCat(JsonElement element)
{
var result = new Cat();
Cat result = new Cat();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("color"))

Просмотреть файл

@ -42,7 +42,7 @@ namespace body_complex.Models.V20160229
}
internal static Cookiecuttershark DeserializeCookiecuttershark(JsonElement element)
{
var result = new Cookiecuttershark();
Cookiecuttershark result = new Cookiecuttershark();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("age"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace body_complex.Models.V20160229
}
internal static DateWrapper DeserializeDateWrapper(JsonElement element)
{
var result = new DateWrapper();
DateWrapper result = new DateWrapper();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("field"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace body_complex.Models.V20160229
}
internal static DatetimeWrapper DeserializeDatetimeWrapper(JsonElement element)
{
var result = new DatetimeWrapper();
DatetimeWrapper result = new DatetimeWrapper();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("field"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace body_complex.Models.V20160229
}
internal static Datetimerfc1123Wrapper DeserializeDatetimerfc1123Wrapper(JsonElement element)
{
var result = new Datetimerfc1123Wrapper();
Datetimerfc1123Wrapper result = new Datetimerfc1123Wrapper();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("field"))

Просмотреть файл

@ -27,7 +27,7 @@ namespace body_complex.Models.V20160229
}
internal static DictionaryWrapper DeserializeDictionaryWrapper(JsonElement element)
{
var result = new DictionaryWrapper();
DictionaryWrapper result = new DictionaryWrapper();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("defaultProgram"))
@ -37,9 +37,9 @@ namespace body_complex.Models.V20160229
continue;
}
result.DefaultProgram = new Dictionary<string, string>();
foreach (var item in property.Value.EnumerateObject())
foreach (var property0 in property.Value.EnumerateObject())
{
result.DefaultProgram.Add(item.Name, item.Value.GetString());
result.DefaultProgram.Add(property0.Name, property0.Value.GetString());
}
continue;
}

Просмотреть файл

@ -30,7 +30,7 @@ namespace body_complex.Models.V20160229
}
internal static Dog DeserializeDog(JsonElement element)
{
var result = new Dog();
Dog result = new Dog();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("food"))

Просмотреть файл

@ -29,7 +29,7 @@ namespace body_complex.Models.V20160229
case "DotSalmon": return DotSalmon.DeserializeDotSalmon(element);
}
}
var result = new DotFish();
DotFish result = new DotFish();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("fish.type"))

Просмотреть файл

@ -46,7 +46,7 @@ namespace body_complex.Models.V20160229
}
internal static DotFishMarket DeserializeDotFishMarket(JsonElement element)
{
var result = new DotFishMarket();
DotFishMarket result = new DotFishMarket();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("sampleSalmon"))

Просмотреть файл

@ -32,7 +32,7 @@ namespace body_complex.Models.V20160229
}
internal static DotSalmon DeserializeDotSalmon(JsonElement element)
{
var result = new DotSalmon();
DotSalmon result = new DotSalmon();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("location"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace body_complex.Models.V20160229
}
internal static DoubleWrapper DeserializeDoubleWrapper(JsonElement element)
{
var result = new DoubleWrapper();
DoubleWrapper result = new DoubleWrapper();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("field1"))

Просмотреть файл

@ -20,7 +20,7 @@ namespace body_complex.Models.V20160229
}
internal static DurationWrapper DeserializeDurationWrapper(JsonElement element)
{
var result = new DurationWrapper();
DurationWrapper result = new DurationWrapper();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("field"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace body_complex.Models.V20160229
}
internal static Error DeserializeError(JsonElement element)
{
var result = new Error();
Error result = new Error();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("status"))

Просмотреть файл

@ -47,7 +47,7 @@ namespace body_complex.Models.V20160229
case "smart_salmon": return SmartSalmon.DeserializeSmartSalmon(element);
}
}
var result = new Fish();
Fish result = new Fish();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("fishtype"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace body_complex.Models.V20160229
}
internal static FloatWrapper DeserializeFloatWrapper(JsonElement element)
{
var result = new FloatWrapper();
FloatWrapper result = new FloatWrapper();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("field1"))

Просмотреть файл

@ -52,7 +52,7 @@ namespace body_complex.Models.V20160229
}
internal static Goblinshark DeserializeGoblinshark(JsonElement element)
{
var result = new Goblinshark();
Goblinshark result = new Goblinshark();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("jawsize"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace body_complex.Models.V20160229
}
internal static IntWrapper DeserializeIntWrapper(JsonElement element)
{
var result = new IntWrapper();
IntWrapper result = new IntWrapper();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("field1"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace body_complex.Models.V20160229
}
internal static LongWrapper DeserializeLongWrapper(JsonElement element)
{
var result = new LongWrapper();
LongWrapper result = new LongWrapper();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("field1"))

Просмотреть файл

@ -20,7 +20,7 @@ namespace body_complex.Models.V20160229
}
internal static MyBaseHelperType DeserializeMyBaseHelperType(JsonElement element)
{
var result = new MyBaseHelperType();
MyBaseHelperType result = new MyBaseHelperType();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("propBH1"))

Просмотреть файл

@ -34,7 +34,7 @@ namespace body_complex.Models.V20160229
case "Kind1": return MyDerivedType.DeserializeMyDerivedType(element);
}
}
var result = new MyBaseType();
MyBaseType result = new MyBaseType();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("kind"))

Просмотреть файл

@ -32,7 +32,7 @@ namespace body_complex.Models.V20160229
}
internal static MyDerivedType DeserializeMyDerivedType(JsonElement element)
{
var result = new MyDerivedType();
MyDerivedType result = new MyDerivedType();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("propD1"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace body_complex.Models.V20160229
}
internal static Pet DeserializePet(JsonElement element)
{
var result = new Pet();
Pet result = new Pet();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("id"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace body_complex.Models.V20160229
}
internal static ReadonlyObj DeserializeReadonlyObj(JsonElement element)
{
var result = new ReadonlyObj();
ReadonlyObj result = new ReadonlyObj();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("id"))

Просмотреть файл

@ -52,7 +52,7 @@ namespace body_complex.Models.V20160229
case "smart_salmon": return SmartSalmon.DeserializeSmartSalmon(element);
}
}
var result = new Salmon();
Salmon result = new Salmon();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("location"))

Просмотреть файл

@ -47,7 +47,7 @@ namespace body_complex.Models.V20160229
}
internal static Sawshark DeserializeSawshark(JsonElement element)
{
var result = new Sawshark();
Sawshark result = new Sawshark();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("picture"))

Просмотреть файл

@ -51,7 +51,7 @@ namespace body_complex.Models.V20160229
case "sawshark": return Sawshark.DeserializeSawshark(element);
}
}
var result = new Shark();
Shark result = new Shark();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("age"))

Просмотреть файл

@ -46,7 +46,7 @@ namespace body_complex.Models.V20160229
}
internal static Siamese DeserializeSiamese(JsonElement element)
{
var result = new Siamese();
Siamese result = new Siamese();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("breed"))

Просмотреть файл

@ -55,7 +55,7 @@ namespace body_complex.Models.V20160229
}
internal static SmartSalmon DeserializeSmartSalmon(JsonElement element)
{
var result = new SmartSalmon();
SmartSalmon result = new SmartSalmon();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("college_degree"))

Просмотреть файл

@ -30,7 +30,7 @@ namespace body_complex.Models.V20160229
}
internal static StringWrapper DeserializeStringWrapper(JsonElement element)
{
var result = new StringWrapper();
StringWrapper result = new StringWrapper();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("field"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace body_date.Models.V100
}
internal static Error DeserializeError(JsonElement element)
{
var result = new Error();
Error result = new Error();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("status"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace body_datetime_rfc1123.Models.V100
}
internal static Error DeserializeError(JsonElement element)
{
var result = new Error();
Error result = new Error();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("status"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace body_datetime.Models.V100
}
internal static Error DeserializeError(JsonElement element)
{
var result = new Error();
Error result = new Error();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("status"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace body_dictionary.Models.V100
}
internal static Error DeserializeError(JsonElement element)
{
var result = new Error();
Error result = new Error();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("status"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace body_dictionary.Models.V100
}
internal static Widget DeserializeWidget(JsonElement element)
{
var result = new Widget();
Widget result = new Widget();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("integer"))

Просмотреть файл

@ -37,9 +37,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, int> value = new Dictionary<string, int>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetInt32());
value.Add(property.Name, property.Value.GetInt32());
}
return Response.FromValue(value, response);
}
@ -75,9 +75,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, int> value = new Dictionary<string, int>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetInt32());
value.Add(property.Name, property.Value.GetInt32());
}
return Response.FromValue(value, response);
}
@ -157,9 +157,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, string> value = new Dictionary<string, string>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetString());
value.Add(property.Name, property.Value.GetString());
}
return Response.FromValue(value, response);
}
@ -195,9 +195,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, string> value = new Dictionary<string, string>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetString());
value.Add(property.Name, property.Value.GetString());
}
return Response.FromValue(value, response);
}
@ -233,9 +233,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, string> value = new Dictionary<string, string>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetString());
value.Add(property.Name, property.Value.GetString());
}
return Response.FromValue(value, response);
}
@ -271,9 +271,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, string> value = new Dictionary<string, string>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetString());
value.Add(property.Name, property.Value.GetString());
}
return Response.FromValue(value, response);
}
@ -309,9 +309,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, bool> value = new Dictionary<string, bool>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetBoolean());
value.Add(property.Name, property.Value.GetBoolean());
}
return Response.FromValue(value, response);
}
@ -391,9 +391,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, bool> value = new Dictionary<string, bool>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetBoolean());
value.Add(property.Name, property.Value.GetBoolean());
}
return Response.FromValue(value, response);
}
@ -429,9 +429,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, bool> value = new Dictionary<string, bool>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetBoolean());
value.Add(property.Name, property.Value.GetBoolean());
}
return Response.FromValue(value, response);
}
@ -467,9 +467,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, int> value = new Dictionary<string, int>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetInt32());
value.Add(property.Name, property.Value.GetInt32());
}
return Response.FromValue(value, response);
}
@ -549,9 +549,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, int> value = new Dictionary<string, int>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetInt32());
value.Add(property.Name, property.Value.GetInt32());
}
return Response.FromValue(value, response);
}
@ -587,9 +587,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, int> value = new Dictionary<string, int>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetInt32());
value.Add(property.Name, property.Value.GetInt32());
}
return Response.FromValue(value, response);
}
@ -625,9 +625,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, long> value = new Dictionary<string, long>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetInt64());
value.Add(property.Name, property.Value.GetInt64());
}
return Response.FromValue(value, response);
}
@ -707,9 +707,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, long> value = new Dictionary<string, long>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetInt64());
value.Add(property.Name, property.Value.GetInt64());
}
return Response.FromValue(value, response);
}
@ -745,9 +745,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, long> value = new Dictionary<string, long>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetInt64());
value.Add(property.Name, property.Value.GetInt64());
}
return Response.FromValue(value, response);
}
@ -783,9 +783,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, float> value = new Dictionary<string, float>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetSingle());
value.Add(property.Name, property.Value.GetSingle());
}
return Response.FromValue(value, response);
}
@ -865,9 +865,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, float> value = new Dictionary<string, float>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetSingle());
value.Add(property.Name, property.Value.GetSingle());
}
return Response.FromValue(value, response);
}
@ -903,9 +903,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, float> value = new Dictionary<string, float>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetSingle());
value.Add(property.Name, property.Value.GetSingle());
}
return Response.FromValue(value, response);
}
@ -941,9 +941,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, double> value = new Dictionary<string, double>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetDouble());
value.Add(property.Name, property.Value.GetDouble());
}
return Response.FromValue(value, response);
}
@ -1023,9 +1023,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, double> value = new Dictionary<string, double>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetDouble());
value.Add(property.Name, property.Value.GetDouble());
}
return Response.FromValue(value, response);
}
@ -1061,9 +1061,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, double> value = new Dictionary<string, double>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetDouble());
value.Add(property.Name, property.Value.GetDouble());
}
return Response.FromValue(value, response);
}
@ -1099,9 +1099,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, string> value = new Dictionary<string, string>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetString());
value.Add(property.Name, property.Value.GetString());
}
return Response.FromValue(value, response);
}
@ -1181,9 +1181,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, string> value = new Dictionary<string, string>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetString());
value.Add(property.Name, property.Value.GetString());
}
return Response.FromValue(value, response);
}
@ -1219,9 +1219,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, string> value = new Dictionary<string, string>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetString());
value.Add(property.Name, property.Value.GetString());
}
return Response.FromValue(value, response);
}
@ -1257,9 +1257,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, DateTimeOffset> value = new Dictionary<string, DateTimeOffset>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetDateTimeOffset());
value.Add(property.Name, property.Value.GetDateTimeOffset("D"));
}
return Response.FromValue(value, response);
}
@ -1298,7 +1298,7 @@ namespace body_dictionary
foreach (var item in arrayBody)
{
content.JsonWriter.WritePropertyName(item.Key);
content.JsonWriter.WriteStringValue(item.Value);
content.JsonWriter.WriteStringValue(item.Value, "D");
}
content.JsonWriter.WriteEndObject();
request.Content = content;
@ -1339,9 +1339,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, DateTimeOffset> value = new Dictionary<string, DateTimeOffset>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetDateTimeOffset());
value.Add(property.Name, property.Value.GetDateTimeOffset("D"));
}
return Response.FromValue(value, response);
}
@ -1377,9 +1377,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, DateTimeOffset> value = new Dictionary<string, DateTimeOffset>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetDateTimeOffset());
value.Add(property.Name, property.Value.GetDateTimeOffset("D"));
}
return Response.FromValue(value, response);
}
@ -1415,9 +1415,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, DateTimeOffset> value = new Dictionary<string, DateTimeOffset>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetDateTimeOffset());
value.Add(property.Name, property.Value.GetDateTimeOffset("S"));
}
return Response.FromValue(value, response);
}
@ -1456,7 +1456,7 @@ namespace body_dictionary
foreach (var item in arrayBody)
{
content.JsonWriter.WritePropertyName(item.Key);
content.JsonWriter.WriteStringValue(item.Value);
content.JsonWriter.WriteStringValue(item.Value, "S");
}
content.JsonWriter.WriteEndObject();
request.Content = content;
@ -1497,9 +1497,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, DateTimeOffset> value = new Dictionary<string, DateTimeOffset>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetDateTimeOffset());
value.Add(property.Name, property.Value.GetDateTimeOffset("S"));
}
return Response.FromValue(value, response);
}
@ -1535,9 +1535,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, DateTimeOffset> value = new Dictionary<string, DateTimeOffset>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetDateTimeOffset());
value.Add(property.Name, property.Value.GetDateTimeOffset("S"));
}
return Response.FromValue(value, response);
}
@ -1573,9 +1573,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, DateTimeOffset> value = new Dictionary<string, DateTimeOffset>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetDateTimeOffset());
value.Add(property.Name, property.Value.GetDateTimeOffset("R"));
}
return Response.FromValue(value, response);
}
@ -1614,7 +1614,7 @@ namespace body_dictionary
foreach (var item in arrayBody)
{
content.JsonWriter.WritePropertyName(item.Key);
content.JsonWriter.WriteStringValue(item.Value);
content.JsonWriter.WriteStringValue(item.Value, "R");
}
content.JsonWriter.WriteEndObject();
request.Content = content;
@ -1655,9 +1655,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, TimeSpan> value = new Dictionary<string, TimeSpan>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetTimeSpan());
value.Add(property.Name, property.Value.GetTimeSpan("P"));
}
return Response.FromValue(value, response);
}
@ -1696,7 +1696,7 @@ namespace body_dictionary
foreach (var item in arrayBody)
{
content.JsonWriter.WritePropertyName(item.Key);
content.JsonWriter.WriteStringValue(item.Value);
content.JsonWriter.WriteStringValue(item.Value, "P");
}
content.JsonWriter.WriteEndObject();
request.Content = content;
@ -1737,9 +1737,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, Byte[]> value = new Dictionary<string, Byte[]>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetBytesFromBase64());
value.Add(property.Name, property.Value.GetBytesFromBase64());
}
return Response.FromValue(value, response);
}
@ -1819,9 +1819,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, Byte[]> value = new Dictionary<string, Byte[]>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetBytesFromBase64());
value.Add(property.Name, property.Value.GetBytesFromBase64());
}
return Response.FromValue(value, response);
}
@ -1857,9 +1857,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, Byte[]> value = new Dictionary<string, Byte[]>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetBytesFromBase64());
value.Add(property.Name, property.Value.GetBytesFromBase64());
}
return Response.FromValue(value, response);
}
@ -1895,9 +1895,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, Widget> value = new Dictionary<string, Widget>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, Widget.DeserializeWidget(item.Value));
value.Add(property.Name, Widget.DeserializeWidget(property.Value));
}
return Response.FromValue(value, response);
}
@ -1933,9 +1933,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, Widget> value = new Dictionary<string, Widget>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, Widget.DeserializeWidget(item.Value));
value.Add(property.Name, Widget.DeserializeWidget(property.Value));
}
return Response.FromValue(value, response);
}
@ -1971,9 +1971,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, Widget> value = new Dictionary<string, Widget>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, Widget.DeserializeWidget(item.Value));
value.Add(property.Name, Widget.DeserializeWidget(property.Value));
}
return Response.FromValue(value, response);
}
@ -2009,9 +2009,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, Widget> value = new Dictionary<string, Widget>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, Widget.DeserializeWidget(item.Value));
value.Add(property.Name, Widget.DeserializeWidget(property.Value));
}
return Response.FromValue(value, response);
}
@ -2047,9 +2047,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, Widget> value = new Dictionary<string, Widget>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, Widget.DeserializeWidget(item.Value));
value.Add(property.Name, Widget.DeserializeWidget(property.Value));
}
return Response.FromValue(value, response);
}
@ -2129,14 +2129,14 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, ICollection<string>> value = new Dictionary<string, ICollection<string>>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
ICollection<string> value0 = new List<string>();
foreach (var item0 in item.Value.EnumerateArray())
foreach (var item in property.Value.EnumerateArray())
{
value0.Add(item0.GetString());
value0.Add(item.GetString());
}
value.Add(item.Name, value0);
value.Add(property.Name, value0);
}
return Response.FromValue(value, response);
}
@ -2172,14 +2172,14 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, ICollection<string>> value = new Dictionary<string, ICollection<string>>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
ICollection<string> value0 = new List<string>();
foreach (var item0 in item.Value.EnumerateArray())
foreach (var item in property.Value.EnumerateArray())
{
value0.Add(item0.GetString());
value0.Add(item.GetString());
}
value.Add(item.Name, value0);
value.Add(property.Name, value0);
}
return Response.FromValue(value, response);
}
@ -2215,14 +2215,14 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, ICollection<string>> value = new Dictionary<string, ICollection<string>>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
ICollection<string> value0 = new List<string>();
foreach (var item0 in item.Value.EnumerateArray())
foreach (var item in property.Value.EnumerateArray())
{
value0.Add(item0.GetString());
value0.Add(item.GetString());
}
value.Add(item.Name, value0);
value.Add(property.Name, value0);
}
return Response.FromValue(value, response);
}
@ -2258,14 +2258,14 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, ICollection<string>> value = new Dictionary<string, ICollection<string>>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
ICollection<string> value0 = new List<string>();
foreach (var item0 in item.Value.EnumerateArray())
foreach (var item in property.Value.EnumerateArray())
{
value0.Add(item0.GetString());
value0.Add(item.GetString());
}
value.Add(item.Name, value0);
value.Add(property.Name, value0);
}
return Response.FromValue(value, response);
}
@ -2301,14 +2301,14 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, ICollection<string>> value = new Dictionary<string, ICollection<string>>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
ICollection<string> value0 = new List<string>();
foreach (var item0 in item.Value.EnumerateArray())
foreach (var item in property.Value.EnumerateArray())
{
value0.Add(item0.GetString());
value0.Add(item.GetString());
}
value.Add(item.Name, value0);
value.Add(property.Name, value0);
}
return Response.FromValue(value, response);
}
@ -2393,9 +2393,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, object> value = new Dictionary<string, object>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetObject());
value.Add(property.Name, property.Value.GetObject());
}
return Response.FromValue(value, response);
}
@ -2431,9 +2431,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, object> value = new Dictionary<string, object>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetObject());
value.Add(property.Name, property.Value.GetObject());
}
return Response.FromValue(value, response);
}
@ -2469,9 +2469,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, object> value = new Dictionary<string, object>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetObject());
value.Add(property.Name, property.Value.GetObject());
}
return Response.FromValue(value, response);
}
@ -2507,9 +2507,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, object> value = new Dictionary<string, object>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetObject());
value.Add(property.Name, property.Value.GetObject());
}
return Response.FromValue(value, response);
}
@ -2545,9 +2545,9 @@ namespace body_dictionary
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
IDictionary<string, object> value = new Dictionary<string, object>();
foreach (var item in document.RootElement.EnumerateObject())
foreach (var property in document.RootElement.EnumerateObject())
{
value.Add(item.Name, item.Value.GetObject());
value.Add(property.Name, property.Value.GetObject());
}
return Response.FromValue(value, response);
}

Просмотреть файл

@ -25,7 +25,7 @@ namespace body_duration.Models.V100
}
internal static Error DeserializeError(JsonElement element)
{
var result = new Error();
Error result = new Error();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("status"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace body_integer.Models.V100
}
internal static Error DeserializeError(JsonElement element)
{
var result = new Error();
Error result = new Error();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("status"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace body_number.Models.V100
}
internal static Error DeserializeError(JsonElement element)
{
var result = new Error();
Error result = new Error();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("status"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace body_string.Models.V100
}
internal static Error DeserializeError(JsonElement element)
{
var result = new Error();
Error result = new Error();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("status"))

Просмотреть файл

@ -22,7 +22,7 @@ namespace body_string.Models.V100
}
internal static RefColorConstant DeserializeRefColorConstant(JsonElement element)
{
var result = new RefColorConstant();
RefColorConstant result = new RefColorConstant();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("ColorConstant"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace custom_baseUrl_more_options.Models.V100
}
internal static Error DeserializeError(JsonElement element)
{
var result = new Error();
Error result = new Error();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("status"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace custom_baseUrl.Models.V100
}
internal static Error DeserializeError(JsonElement element)
{
var result = new Error();
Error result = new Error();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("status"))

Просмотреть файл

@ -27,7 +27,7 @@ namespace extensible_enums_swagger.Models.V20160707
}
internal static Pet DeserializePet(JsonElement element)
{
var result = new Pet();
Pet result = new Pet();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("name"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace header.Models.V100
}
internal static Error DeserializeError(JsonElement element)
{
var result = new Error();
Error result = new Error();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("status"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace url_multi_collectionFormat.Models.V100
}
internal static Error DeserializeError(JsonElement element)
{
var result = new Error();
Error result = new Error();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("status"))

Просмотреть файл

@ -25,7 +25,7 @@ namespace url.Models.V100
}
internal static Error DeserializeError(JsonElement element)
{
var result = new Error();
Error result = new Error();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("status"))

Просмотреть файл

@ -22,7 +22,7 @@ namespace validation.Models.V100
}
internal static ChildProduct DeserializeChildProduct(JsonElement element)
{
var result = new ChildProduct();
ChildProduct result = new ChildProduct();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("constProperty"))

Просмотреть файл

@ -19,7 +19,7 @@ namespace validation.Models.V100
}
internal static ConstantProduct DeserializeConstantProduct(JsonElement element)
{
var result = new ConstantProduct();
ConstantProduct result = new ConstantProduct();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("constProperty"))

Просмотреть файл

@ -30,7 +30,7 @@ namespace validation.Models.V100
}
internal static Error DeserializeError(JsonElement element)
{
var result = new Error();
Error result = new Error();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("code"))

Просмотреть файл

@ -40,13 +40,16 @@ namespace validation.Models.V100
writer.WriteNumberValue(ConstInt);
writer.WritePropertyName("constString");
writer.WriteStringValue(ConstString);
writer.WritePropertyName("constStringAsEnum");
writer.WriteStringValue(ConstStringAsEnum);
if (ConstStringAsEnum != null)
{
writer.WritePropertyName("constStringAsEnum");
writer.WriteStringValue(ConstStringAsEnum);
}
writer.WriteEndObject();
}
internal static Product DeserializeProduct(JsonElement element)
{
var result = new Product();
Product result = new Product();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("display_names"))
@ -102,6 +105,10 @@ namespace validation.Models.V100
}
if (property.NameEquals("constStringAsEnum"))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
result.ConstStringAsEnum = property.Value.GetString();
continue;
}