public override ItemDefinition Read()

in src/managed/DiffGen/ArchiveUtility/ItemDefinitionJsonConverter.cs [19:70]


        public override ItemDefinition Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            reader.CheckStartObject();

            UInt64? length = null;
            Dictionary<HashAlgorithmType, Hash> hashes = new();
            List<string> names = new();

            while (reader.Read())
            {
                if (reader.TokenType == JsonTokenType.EndObject)
                {
                    break;
                }

                if (reader.TokenType != JsonTokenType.PropertyName)
                {
                    throw new JsonException();
                }

                string property = reader.GetString();

                if (property == null)
                {
                    throw new JsonException();
                }

                reader.Read();

                switch (property)
                {
                    case "Length":
                        length = reader.GetUInt64();
                        break;
                    case "Hashes":
                        hashes = JsonSerializer.Deserialize<Dictionary<HashAlgorithmType, Hash>>(ref reader, options);
                        break;
                    case "Names":
                        names = JsonSerializer.Deserialize<List<string>>(ref reader, options);
                        break;
                    default:
                        throw new JsonException();
                }
            }

            if (length == null)
            {
                throw new JsonException();
            }

            return new(length.Value, hashes, names);
        }