Add JSON schema generation/validation and structured configuration diagnostics#288
Merged
Conversation
The BV1100 (invalid JSON) diagnostic computed its column from JsonException.BytePositionInLine, a byte offset, while schema-validation diagnostics report character-based columns via JsonSourceMap. On a line with multi-byte characters before the error the two disagreed, so the clickable file(line,column) link landed past the real position. Convert the byte position to a character column with Encoding.UTF8.GetCharCount. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
JsonSchemaValidationError.DisplayPath was reconstructed from the JSON Pointer after the fact, inferring array-index vs object-key from whether a token was all digits, so an all-digit dictionary key rendered as an array index ([1] instead of .1). Thread a display path alongside the pointer through the validator, where the structural context is known: object members render as .name and array elements as [index], so a numeric object key is never mistaken for an index. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Member
Author
|
This PR has been reviewed locally. |
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.
Summary
Introduces
Buildvana.Core.JsonSchema, a model-independent library that generates a JSON Schema (draft 2020-12) from a .NET type and validates a parsed document against it, reporting each failure with a kind, a JSON Pointer, and a 1-based source line/column. The configuration loader (buildvana.json/.jsonc) now uses it, surfacing schema violations as structuredBuildDiagnostics thatbvrenders in canonicalfile(line,column): error CODE: messageform (clickable in VS Code).The repository-root configuration file remains inert (discovered, parsed, validated, exposed — but no setting affects the build yet), as already noted in the changelog.
What's included
Buildvana.Core.JsonSchema—JsonSchemaGenerator(attribute-driven:[Description],[JsonNullable],[JsonAllowedKeys],[JsonSchemaTitle]),JsonSchemaValidator(subset of draft 2020-12:type,enum,properties,required,additionalProperties,items,$ref), andJsonSourceMap(pointer → 1-based line/column over UTF-8). The sameJsonSerializerOptionsdrive generation and deserialization, so the committed schema always matches what the loader accepts.BuildDiagnostic/BuildDiagnosticSeverityand aBuildFailedException.Diagnosticslist;bvprints each diagnostic verbatim in compiler format.JsonNode, validates against the generated schema, then deserializes; codes BV1100–BV1105 documented indocs/ToolDiagnostics.md.Buildvana.Core.JsonSchema.TestsandBuildvana.Core.Configuration.Testsprojects.schemas/buildvana.schema.json.Note: unrelated
DotNetConfigrestructuringCommit
4eb1c16restructuresDotNetConfiginto per-command invocation config (all/restore/build/test/pack/nugetPush), each withargs+env. This is unrelated, preparatory work for the next PR; it landed on this branch and is too late to factor out cleanly, so it rides along here. It only reshapes the (inert) configuration model.Testing
dotnet build Buildvana.slnxclean (0 warnings); the JsonSchema (22) and Configuration (7) test suites pass.