private async Task WriteObjectPropertyDeserializationAsync(
            CodeWriter writer,
            IResultParserTypeDescriptor possibleType,
            string jsonElement,
            ITypeLookup typeLookup)
        {
            for (int i = 0; i < possibleType.ResultDescriptor.Fields.Count; i++)
            {
                IFieldDescriptor fieldDescriptor = possibleType.ResultDescriptor.Fields[i];

                await writer.WriteIndentAsync().ConfigureAwait(false);

                if (fieldDescriptor.Type.NamedType().IsLeafType())
                {
                    ITypeInfo typeInfo = typeLookup.GetTypeInfo(
                        fieldDescriptor.Type,
                        true);

                    string deserializeMethod =
                        SerializerNameUtils.CreateDeserializerName(
                            fieldDescriptor.Type);

                    await writer.WriteAsync(deserializeMethod).ConfigureAwait(false);

                    await writer.WriteAsync('(').ConfigureAwait(false);

                    await writer.WriteAsync(jsonElement).ConfigureAwait(false);

                    await writer.WriteAsync(", \"").ConfigureAwait(false);

                    await writer.WriteAsync(fieldDescriptor.ResponseName).ConfigureAwait(false);

                    await writer.WriteAsync("\")").ConfigureAwait(false);
                }
                else
                {
                    await writer.WriteAsync("Parse").ConfigureAwait(false);

                    await writer.WriteAsync(GetPathName(fieldDescriptor.Path))
                    .ConfigureAwait(false);

                    await writer.WriteAsync('(').ConfigureAwait(false);

                    await writer.WriteAsync(jsonElement).ConfigureAwait(false);

                    await writer.WriteAsync(", \"").ConfigureAwait(false);

                    await writer.WriteAsync(fieldDescriptor.ResponseName).ConfigureAwait(false);

                    await writer.WriteAsync("\")").ConfigureAwait(false);
                }

                if (i < possibleType.ResultDescriptor.Fields.Count - 1)
                {
                    await writer.WriteAsync(',').ConfigureAwait(false);
                }

                await writer.WriteLineAsync().ConfigureAwait(false);
            }
        }
        private async Task WriteDeserializeMethodAsync(
            CodeWriter writer,
            IResultParserTypeDescriptor possibleType,
            ITypeLookup typeLookup,
            ISet <string> generatedMethods)
        {
            bool first = true;

            foreach (IType type in possibleType.ResultDescriptor.Fields
                     .Where(t => t.Type.NamedType().IsLeafType())
                     .Select(t => t.Type))
            {
                string methodName = SerializerNameUtils.CreateDeserializerName(type);

                if (generatedMethods.Add(methodName))
                {
                    Type   serializationType = typeLookup.GetSerializationType(type);
                    string serializerMethod  = _jsonMethod[serializationType];

                    if (!first)
                    {
                        await writer.WriteLineAsync().ConfigureAwait(false);
                    }
                    first = false;

                    if (type.IsListType() && type.ListType().ElementType.IsListType())
                    {
                        // TODO : implement this
                        throw new NotImplementedException();
                    }
                    else if (type.IsListType() &&
                             type.ListType().ElementType.IsLeafType())
                    {
                        await WriteDeserializeLeafListAsync(
                            writer,
                            typeLookup,
                            methodName,
                            type,
                            type.NamedType().Name,
                            serializerMethod)
                        .ConfigureAwait(false);
                    }
                    else
                    {
                        await WriteDeserializeLeafAsync(
                            writer,
                            methodName,
                            typeLookup.GetLeafClrTypeName(type),
                            type.NamedType().Name,
                            serializerMethod,
                            type.IsNonNullType())
                        .ConfigureAwait(false);
                    }
                }
            }
        }