Skip to content

Release 0.1.1: fix SceneJson.CreateOptions and validate the package - #4

Merged
mahach666 merged 2 commits into
mainfrom
release/0.1.1
Nov 13, 2026
Merged

mahach666 merged 2 commits into
mainfrom
release/0.1.1

Conversation

@mahach666

Copy link
Copy Markdown
Contributor

Release 0.1.1: two fixes in SceneJson.CreateOptions(), package validation against 0.1.0, and the README of the package with the range nuget.org accepts (#3).

What changes and why

SceneJson.CreateOptions() (src/IOScene/SceneJson.cs, the Harden modifier)

  • Rejection on a runtime without dynamic code. System.Text.Json then calls the init setters of SceneDocument.Kind and Format through reflection, which wraps their InvalidDataException in a TargetInvocationException. A document read with these options got that wrapper for a scene of another kind or a newer format. The options now wrap those two setters and rethrow the InvalidDataException itself (ExceptionDispatchInfo). SceneJson.Read/Load caught the wrapper themselves; that catch is removed, and they now throw the setter's exception as with dynamic code (same type and message, no TargetInvocationException as inner exception).
  • IJsonOnDeserialized of a holder. Harden assigned JsonTypeInfo.OnDeserialized for every type with a list of objects or strings, which replaced the callback System.Text.Json sets for a type implementing IJsonOnDeserialized. The previous callback is kept and runs after the check for null entries.
  • Required members of a holder. The exception for required members applied to every type, so a member a holder marks [JsonRequired] or required kept an explicit null and its list was not checked for null entries, unlike what the method's documentation says. Only SceneDocument.Kind and Format keep their own checks now; a holder's required member follows the rules of the options.

Package and CI

  • src/IOScene/IOScene.csproj: EnablePackageValidation with PackageValidationBaselineVersion 0.1.0, so dotnet pack fails on a removed or changed public member. CONTRIBUTING says how the baseline moves with a breaking minor.
  • ci.yml: a step that runs the tests again with -p:DynamicCodeSupport=false (the SDK property behind RuntimeFeature.IsDynamicCodeSupported).
  • Version 0.1.1; CHANGELOG.md section ## [0.1.1] - 2026-11-13 (with the entries of Recommend a range for IOScene that nuget.org accepts #3); docs/contract.md says which exception a wrong Kind/Format gives with and without these options; the XML doc of CreateOptions covers both fixes.

Checks

  • Before the fix, a scratch app against the project showed the defects: without dynamic code a holder with another kind or format got TargetInvocationException; with and without dynamic code the holder's OnDeserialized did not run. After the fix every case passes in both modes.
  • New tests: another kind or format in a holder gives InvalidDataException; the holder's OnDeserialized runs once and after the null check (the test callback throws another type if it runs first); a holder's [JsonRequired] list reads null as missing and rejects a null entry. Without the respective fix the tests fail (the first one in the mode without dynamic code; the required-holder test was checked by removing the narrowing).
  • dotnet build -c Release: 0 warnings. dotnet test: 239 passed on net8.0 and net10.0, and again 239 on both with -p:DynamicCodeSupport=false (the test runtimeconfig has IsDynamicCodeSupported: false).
  • dotnet pack with validation passes against IOScene 0.1.0 from nuget.org; making CreateOptions internal makes it fail with CP0002. The package has no dependencies, and its README has the range [0.1.0, 0.2.0-0.0).
  • Independent review (10 agents): 6 findings confirmed and fixed (the required-member scope, the order check in the test, the SDK property, two CHANGELOG wordings).
  • Not run: the release workflow (tag v0.1.1).

After merge

Tag v0.1.1 on the merge commit. The CHANGELOG date is 2026-11-13; if the tag is pushed on a later day, the date should be corrected first.

Without dynamic code System.Text.Json calls the setters of Kind and Format
through reflection, which wrapped their InvalidDataException in a
TargetInvocationException for a document read with CreateOptions. The options
now unwrap it at the setter, so SceneJson.Read no longer needs its own catch.
The options also replaced the OnDeserialized callback that System.Text.Json
sets for a type implementing IJsonOnDeserialized; the callback runs again,
after the check for null list entries. A member that a holder marks required
now follows the rules of the options, as their documentation says; only Kind
and Format keep their own checks.

dotnet pack compares the public API with 0.1.0 (package validation), and CI
runs the tests again with DynamicCodeSupport=false. Version 0.1.1.
@mahach666
mahach666 merged commit 1624ef6 into main Nov 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant