Tatenda-k commented on issue #1799: URL: https://github.com/apache/fory/issues/1799#issuecomment-4759863584
Hi again! May be assigned to this issue. Here is my plan: ## Planned changes * **Add ****`ForyExtraFields`**** type** — a `HashMap<String, Object>` subclass that stores captured unmatched fields along with a transient `TypeDef`. A class opts into unknown-field preservation by declaring one field of this type. * **Detection/exclusion in ****`TypeResolver.buildFieldDescriptors`** — the `ForyExtraFields` field is removed from the normal serialized field set and registered as the capture sink. * **Capture (read)** — `CompatibleSerializer.readAndSetField` and `CompatibleSerializer.setFieldValue` will handle unmatched fields instead of skipping them. The decoded values will be stored in the `ForyExtraFields` capture sink along with the remote `TypeDef`. * **Replay (write)** — `CompatibleCodecBuilder.buildEncodeExpression` will generate serialization code based on the original remote schema (`TypeDef`). `ObjectSerializer.write` will detect when captured extra fields belong to a different schema version and delegate serialization to `buildEncodeExpression` instead of the normal serialization path. **Note:** Capture and replay both reuse the session reference context (`RefReader`/`RefWriter`), so reference sharing between extra fields and local fields is preserved. Remaining limitation: if a referenced object's type is unknown locally, it will be represented as an `UnknownClass` placeholder. ## Tests * **Round-trip test** — Verify that unknown fields are preserved instead of lost. * **Reference-sharing test** — Verify that object identity is preserved between local and captured fields. * **Zero-overhead test** — Verify that classes without a capture sink maintain the same serialization behavior as before. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
