feat(stjm): add per-target undiscriminated source migration support#26
Merged
feat(stjm): add per-target undiscriminated source migration support#26
Conversation
48dbd7c to
bfe7cca
Compare
Introduces JsonMigratableAttribute.UndiscriminatedSourceType so a target type can opt in to treating discriminator-less object payloads as a specific source type and run the matching migrator. Without this opt-in, behavior is unchanged: discriminator-less objects deserialize directly as the target type. This enables incremental adoption of migration on existing types where stored JSON has no $type discriminator. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
bfe7cca to
d026587
Compare
…s guidance [skip notes] Introduces a repo-wide AGENTS.md that documents the Conventional Commit scopes for every project (stjm, oes, os, ot, stp), the cross-cutting scopes (ci, build, docs), and the [skip notes] marker used to exclude irrelevant commits from generated package release notes. Per-project AGENTS.md files continue to govern project-specific build/test conventions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds BenchmarkDotNet coverage for the per-target undiscriminated source migration path with a plain System.Text.Json manual migration baseline. This keeps the new code path visible in future performance comparisons without adding a package-consumer release note entry. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…arks [skip notes] Copies the latest BenchmarkDotNet report output into docs/perf and updates the README performance summary to include the undiscriminated source migration scenario. The summary generator now keeps that scenario in future refreshes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Documents how to refresh benchmark-backed performance docs after running the BenchmarkDotNet suite, and makes the update script consume reports from either the perf project artifact folder or the project-root artifact folder. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
When adopting
Egil.SystemTextJson.Migrationon an existing type, stored JSON typically has no$typediscriminator. Today, discriminator-less object payloads are deserialized directly as the target type, which makes it hard to incrementally introduce a renamed/restructured target with a migration from the prior shape.Approach
Adds an opt-in
JsonMigratableAttribute.UndiscriminatedSourceTypethat lets a target declare a single source CLR type to assume when an object payload has no recognized discriminator. The converter then runs the matching migrator (staticIMigrateFrom<>on the target, or an externalIMigrate<,>registration). Behavior without the attribute is unchanged.Internals:
TypeMetadatacarries the configured undiscriminated source type.JsonMigratableConverterFactoryresolves the matchingMigratorReferenceonce per converter and throws a clearInvalidOperationExceptionat setup time if no migrator matches.JsonMigratableConverter.Inspectconsults the resolved migrator at the empty-object branch and after the source-discriminator scan, before the dictionary-payload fallback.Performance
Added BenchmarkDotNet coverage for the new undiscriminated source migration route with a plain System.Text.Json manual migration baseline. Refreshed the generated
docs/perfreports and README performance summary from those results. Ran the full perf suite on this machine in both directions: changed branch first, then a detachedmainworktree baseline.Common benchmark rows compared: 72. New changed-branch benchmark rows: 12. No allocation deltas were observed across common rows. The only common-row slowdowns were small/noisy: +5.2% on a plain STJ serialize baseline at tag count 2, and +0.6% to +0.9% on existing external migration rows; all other common rows were equal or faster in this run.
New undiscriminated source migration benchmark results:
Notes for reviewers
$type(or a known source discriminator) keep their current routing.UndiscriminatedStaticTargetdeclares twoIMigrateFrom<>impls and verifies the configured one wins.README, recipes) and theLegacyPayloadssample are updated with the new pattern; mdsnippets refreshed.mainbaseline.