Repository navigation
Refuse NaN and infinities in the data-record number setters [patch] - #352
Open
matt-edmondson wants to merge 5 commits into
Open
matt-edmondson wants to merge 5 commits into
matt-edmondson wants to merge 5 commits into
Conversation
SetFloat, SetDouble and the vector and colour setters stored any value, and JSON has no number for NaN or an infinity. The record then threw on the next ToJsonString, so the generated editor's Issues, IsValid, ToJson and Save all threw until the value was overwritten. The setters now throw an ArgumentOutOfRangeException naming the member before anything is written. Fixes #350 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW67k6oxx5vQPHu3V4Q
…ix CA1506 [patch] #332 tipped Schema's class coupling to 97 against a limit of 96, and CA1506 is an error here, so main stopped building on every target framework. Move the data-source file-existence check and the reserved-generator-name check into an internal SchemaEnvironmentValidator. They are the two checks that consult something outside the schema, and with them gone Schema no longer reaches File, the IO exceptions, SchemaGenerator or ISchemaCodeGenerator. Behaviour is unchanged. Fixes #336 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW67k6oxx5vQPHu3V4Q
Contributor
Author
|
The I merged the fix from #353 into this branch (30fab8d) so CI can build. With it, the solution builds with analyzers on (0 errors, 0 warnings) and Schema.Test passes 720/720 locally. Once #353 merges first, that commit drops out of this PR's diff. Generated by Claude Code |
File.Exists returns false instead of throwing for a path it can't read, so the IOException/UnauthorizedAccessException branch never ran. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW67k6oxx5vQPHu3V4Q
|
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.



Fixes #350
What changed
SchemaDataValues.SetFloat,SetDoubleandSetComponents(used bySetVector2/3/4andSetColorRgb/Rgba) stored non-finite values without complaint. JSON has no number for those values, so the record threw on its nextToJsonString. The generated editor'sIssues,IsValid,ToJsonandSaveall go through that call, so they threw too, until the value was overwritten.Each of these setters now throws an
ArgumentOutOfRangeExceptionnaming the member before it writes anything. A vector or colour has every component checked before the array is built, so a refused assignment leaves the record as it was.Tests (
GeneratedDataEditorTests)TestANonFiniteValueIsRefusedAndTheEditorKeepsWorking: on a generated record, assigning NaN, +∞ or −∞ toWeight, or a NaN component toTint, is refused with the member named. Afterwards the record keeps its previous values,Issuesmatches what it was before,IsValidis true,ToJsonreturns the loaded text, andSavesucceeds.TestNonFiniteNumbersAreRefusedBeforeTheRecordChanges: coversSetDouble,SetFloat,SetVector2/3/4andSetColorRgbadirectly, and checks that the record's JSON is unchanged.Note on CI
maindoesn't build right now because of #336 (CA1506 onSchema, class coupling 97 against a limit of 96). This PR doesn't touchSchema.cs, so it will show the same failure until #336 is fixed. I ran the suites above with-p:RunAnalyzers=false, then ran the analyzers on the changed test project on its own: they reported nothing. The only analyzer error in the library is the existing CA1506.Generated by Claude Code