Replace YamlDotNet with SharpYaml (source-gen + reflection fallback)#7
Merged
Conversation
Swap YamlDotNet 16.3.0 for SharpYaml 3.7.0 across front matter, data files, and the llms/redirect sidecar readers. Built-in front-matter records deserialize through a source-generated YamlSerializerContext (PenningtonYamlContext); the DocSite/BlogSite templates ship their own contexts; users opt in via AddPenningtonYamlContext. Any type no context covers falls back to reflection through an explicit ReflectionYamlTypeInfoResolver, so the fallback works regardless of SharpYaml's IsReflectionEnabledByDefault switch. FrontMatterParser enforces the anchor/alias/tag security policy with a single SharpYaml event pass (replacing SafeYamlParser/BufferedYamlParser) and reports unknown keys with line numbers. Strict mode throws from that scan after emitting warnings, so it works uniformly for source-gen and reflection types.
MultipleSourcesExample registers BlogFrontMatterYamlContext via AddPenningtonYamlContext, exercising the user opt-in source-gen path alongside the built-in context (DocFrontMatter) and reflection fallback in one host.
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.
What
Replaces YamlDotNet 16.3.0 with SharpYaml 3.7.0 across all YAML deserialization: front matter, data files (
DataFileLoader), and the_llms.yaml/_redirects.ymlsidecar readers. YamlDotNet is removed entirely.How it's wired
DocFrontMatter,BlogFrontMatter) deserialize through a source-generatedYamlSerializerContext(PenningtonYamlContext). The DocSite/BlogSite templates register their own contexts; end users opt in withservices.AddPenningtonYamlContext(MyContext.Default). Any type no context covers falls back to reflection.ReflectionYamlTypeInfoResolver.Default, so it works regardless of SharpYaml'sIsReflectionEnabledByDefaultswitch.PenningtonYamlContextProviderroutes each type to the context that knows it (or reflection) rather than chaining contexts into one resolver.FrontMatterParserenforces the anchor/alias/non-standard-tag policy in a single SharpYaml event pass (replacingSafeYamlParser+BufferedYamlParser, both deleted), and reports unknown keys with line numbers. Strict mode throws from that scan after emitting warnings, so it behaves identically for source-gen and reflection types.Example
examples/MultipleSourcesExamplenow registers a customBlogFrontMatterYamlContextviaAddPenningtonYamlContext, exercising the user opt-in path alongside the built-in context and reflection fallback in one host.Verification
dotnet build Pennington.slnx— clean, 0 warnings.dotnet test Pennington.slnx— 801 unit + 131 Roslyn + 40 TreeSitter + 48 integration pass (9 pre-existing skips). Covers diagnostics line numbers, strict-mode throw, and the anchor/.NET-type-tag security tests.dotnet run --project docs/Pennington.Docs -- build— 475 pages, exit 0.dotnet run --project examples/MultipleSourcesExample -- build— blog pages render theirBlogFrontMatter-sourced titles through the registered context.Note for AOT
The reflection fallback (data files, sidecar POCOs) is the default for non-AOT builds. Under
PublishAot, those would need<SharpYamlIsReflectionEnabledByDefault>true</...>or the types registered in a context; the front-matter types are already AOT-safe via source-gen.