Repository navigation
Release 0.1.1: fix SceneJson.CreateOptions and validate the package - #4
Merged
Merged
Conversation
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.
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.
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, theHardenmodifier)initsetters ofSceneDocument.KindandFormatthrough reflection, which wraps theirInvalidDataExceptionin aTargetInvocationException. 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 theInvalidDataExceptionitself (ExceptionDispatchInfo).SceneJson.Read/Loadcaught the wrapper themselves; that catch is removed, and they now throw the setter's exception as with dynamic code (same type and message, noTargetInvocationExceptionas inner exception).IJsonOnDeserializedof a holder.HardenassignedJsonTypeInfo.OnDeserializedfor every type with a list of objects or strings, which replaced the callback System.Text.Json sets for a type implementingIJsonOnDeserialized. The previous callback is kept and runs after the check for null entries.[JsonRequired]orrequiredkept an explicitnulland its list was not checked for null entries, unlike what the method's documentation says. OnlySceneDocument.KindandFormatkeep their own checks now; a holder's required member follows the rules of the options.Package and CI
src/IOScene/IOScene.csproj:EnablePackageValidationwithPackageValidationBaselineVersion0.1.0, sodotnet packfails 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 behindRuntimeFeature.IsDynamicCodeSupported).CHANGELOG.mdsection## [0.1.1] - 2026-11-13(with the entries of Recommend a range for IOScene that nuget.org accepts #3);docs/contract.mdsays which exception a wrongKind/Formatgives with and without these options; the XML doc ofCreateOptionscovers both fixes.Checks
TargetInvocationException; with and without dynamic code the holder'sOnDeserializeddid not run. After the fix every case passes in both modes.InvalidDataException; the holder'sOnDeserializedruns once and after the null check (the test callback throws another type if it runs first); a holder's[JsonRequired]list readsnullas 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 hasIsDynamicCodeSupported: false).dotnet packwith validation passes against IOScene 0.1.0 from nuget.org; makingCreateOptionsinternal makes it fail with CP0002. The package has no dependencies, and its README has the range[0.1.0, 0.2.0-0.0).v0.1.1).After merge
Tag
v0.1.1on 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.