Repository navigation
(PATCH): Extract the patch class model from PatchClassBuilder - #129
Merged
Merged
Conversation
Move the decisions about what a patch class contains (record detection, constructor selection and binding, property selection, and the attributes carried onto each Optional<T> property) into an internal PatchClassModel, so a second builder can share them. PatchClassBuilder turns the model into CodeDom exactly as before. The IsVisible check stays in the Roslyn builder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cover the cases the builder tests only reach end to end: positional records, constructor-bound get-only properties, [JsonConstructor], hidden properties, ignored properties, and repeated validators of one type. The core project now exposes its internals to the test project. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
✅ PR Title Formatted CorrectlyThe title of this PR has been updated to match the correct format. Thank you! |
This was referenced Oct 1, 2026
PaulTrampert
pushed a commit
to PaulTrampert/PacmanManager
that referenced
this pull request
Oct 6, 2026
Updated [PTrampert.SimplePatch](https://github.com/PaulTrampert/PTrampert.SimplePatch) from 1.3.6 to 2.0.3. <details> <summary>Release notes</summary> _Sourced from [PTrampert.SimplePatch's releases](https://github.com/PaulTrampert/PTrampert.SimplePatch/releases)._ ## 2.0.3 ## Changes - (PATCH): Drop the Roslyn patch class builder's own cache ([#154](PaulTrampert/PTrampert.SimplePatch#154)) ## 2.0.2 ## Changes - (PATCH): Route PatchClassBuilder.Instance through CachingPatchClassBuilder ([#155](PaulTrampert/PTrampert.SimplePatch#155)) ## 2.0.1 ## Changes - (PATCH): Add an internal CachingPatchClassBuilder decorator ([#153](PaulTrampert/PTrampert.SimplePatch#153)) - (PATCH): Document the release PR format for staged release branches ([#152](PaulTrampert/PTrampert.SimplePatch#152)) ## 2.0.0 ## Changes - (MAJOR): Release 2.0 ([#147](PaulTrampert/PTrampert.SimplePatch#147)) - (PATCH): Build PRs into release/** branches and document the release flow ([#146](PaulTrampert/PTrampert.SimplePatch#146)) ## 1.5.0 ## What's Changed * (MINOR): Add PatchClassBuilder.UseExperimentalDynamicClassBuilder by @PaulTrampert in PaulTrampert/PTrampert.SimplePatch#136 **Full Changelog**: PaulTrampert/PTrampert.SimplePatch@v1.4.0...v1.5.0 ## 1.4.0 ## What's Changed * (MINOR): Add IPatchClassBuilder, with PatchClassBuilder delegating to an internal RoslynPatchClassBuilder by @PaulTrampert in PaulTrampert/PTrampert.SimplePatch#133 **Full Changelog**: PaulTrampert/PTrampert.SimplePatch@v1.3.8...v1.4.0 ## 1.3.8 ## What's Changed * (PATCH): Add an internal Reflection.Emit patch class builder by @PaulTrampert in PaulTrampert/PTrampert.SimplePatch#130 **Full Changelog**: PaulTrampert/PTrampert.SimplePatch@v1.3.7...v1.3.8 ## 1.3.7 ## What's Changed * (PATCH): Bump the csharp-deps group with 6 updates by @dependabot[bot] in PaulTrampert/PTrampert.SimplePatch#81 * (PATCH): Add AGENTS.md, CLAUDE.md symlink and /implement-unblocked by @PaulTrampert in PaulTrampert/PTrampert.SimplePatch#125 * (PATCH): Extract the patch class model from PatchClassBuilder by @PaulTrampert in PaulTrampert/PTrampert.SimplePatch#129 **Full Changelog**: PaulTrampert/PTrampert.SimplePatch@v1.3.6...v1.3.7 Commits viewable in [compare view](PaulTrampert/PTrampert.SimplePatch@v1.3.6...v2.0.3). </details> Updated [PTrampert.SimplePatch.Swashbuckle](https://github.com/PaulTrampert/PTrampert.SimplePatch) from 1.3.6 to 2.0.3. <details> <summary>Release notes</summary> _Sourced from [PTrampert.SimplePatch.Swashbuckle's releases](https://github.com/PaulTrampert/PTrampert.SimplePatch/releases)._ ## 2.0.3 ## Changes - (PATCH): Drop the Roslyn patch class builder's own cache ([#154](PaulTrampert/PTrampert.SimplePatch#154)) ## 2.0.2 ## Changes - (PATCH): Route PatchClassBuilder.Instance through CachingPatchClassBuilder ([#155](PaulTrampert/PTrampert.SimplePatch#155)) ## 2.0.1 ## Changes - (PATCH): Add an internal CachingPatchClassBuilder decorator ([#153](PaulTrampert/PTrampert.SimplePatch#153)) - (PATCH): Document the release PR format for staged release branches ([#152](PaulTrampert/PTrampert.SimplePatch#152)) ## 2.0.0 ## Changes - (MAJOR): Release 2.0 ([#147](PaulTrampert/PTrampert.SimplePatch#147)) - (PATCH): Build PRs into release/** branches and document the release flow ([#146](PaulTrampert/PTrampert.SimplePatch#146)) ## 1.5.0 ## What's Changed * (MINOR): Add PatchClassBuilder.UseExperimentalDynamicClassBuilder by @PaulTrampert in PaulTrampert/PTrampert.SimplePatch#136 **Full Changelog**: PaulTrampert/PTrampert.SimplePatch@v1.4.0...v1.5.0 ## 1.4.0 ## What's Changed * (MINOR): Add IPatchClassBuilder, with PatchClassBuilder delegating to an internal RoslynPatchClassBuilder by @PaulTrampert in PaulTrampert/PTrampert.SimplePatch#133 **Full Changelog**: PaulTrampert/PTrampert.SimplePatch@v1.3.8...v1.4.0 ## 1.3.8 ## What's Changed * (PATCH): Add an internal Reflection.Emit patch class builder by @PaulTrampert in PaulTrampert/PTrampert.SimplePatch#130 **Full Changelog**: PaulTrampert/PTrampert.SimplePatch@v1.3.7...v1.3.8 ## 1.3.7 ## What's Changed * (PATCH): Bump the csharp-deps group with 6 updates by @dependabot[bot] in PaulTrampert/PTrampert.SimplePatch#81 * (PATCH): Add AGENTS.md, CLAUDE.md symlink and /implement-unblocked by @PaulTrampert in PaulTrampert/PTrampert.SimplePatch#125 * (PATCH): Extract the patch class model from PatchClassBuilder by @PaulTrampert in PaulTrampert/PTrampert.SimplePatch#129 **Full Changelog**: PaulTrampert/PTrampert.SimplePatch@v1.3.6...v1.3.7 Commits viewable in [compare view](PaulTrampert/PTrampert.SimplePatch@v1.3.6...v2.0.3). </details> Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore <dependency name> major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore <dependency name> minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore <dependency name>` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore <dependency name>` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore <dependency name> <ignore condition>` will remove the ignore condition of the specified dependency and ignore conditions </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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.
Closes #127
What and why
Groundwork for the Reflection.Emit builder (#95). The decisions about what a patch class contains move out of
PatchClassBuilder.CreatePatchClassinto a new internalPatchClassModel, so a second builder can share them instead of copying them and drifting (the bug class behind #87–#93). Doing the move here keeps the Emit PR's diff to new IL only.PatchClassModel.For(type)holds:IsRecord(the<Clone>$check),ConstructorandConstructorProperties(System.Text.Json's constructor selection and case-insensitive parameter binding, in parameter order),OptionalPropertiesandIgnoredProperties(most-derived properties with a public setter or init accessor, or bound by the constructor, split on[JsonIgnore(Condition = Always)]),OptionalPropertyModelwithHasConverter,JsonPropertyName, andValidators(OptionalValidatorModel(type, index), with the index counted per validator type).PatchClassBuilderturns the model into CodeDom/C# exactly as before. The helper methods moved verbatim (IsRecordbecameDetectRecordso it doesn't clash with the property). Some things stayed in the builder on purpose, because they're about generating the class, not about what it contains:IsVisiblecheck and itsNotSupportedException, which is a Roslyn restriction. It still runs before the model is built, so the order of exceptions is unchanged;withexpression for records;No public API changes. The model types are internal, and the core project gains
[InternalsVisibleTo("PTrampert.SimplePatch.Test")](as anInternalsVisibleToitem in the csproj).Alternatives rejected
JsonConverterAttributeinstance in the model instead of aHasConverterflag. The generated attribute only ever needs the source type and property name, so the flag is all a builder needs.Tests
PatchClassBuilderTestpasses unchanged.PatchClassModelTest(10 tests) covers the model directly: positional records, constructor-bound get-only properties (including a[JsonIgnore]one), a get-only property not in the constructor,[JsonConstructor], ambiguous constructors, hidden properties,JsonIgnoreconditions, carried attributes, and repeated validators of one type. This is a pure refactor, so these tests pin the behaviour rather than reproduce a bug. They don't compile before the change because the model didn't exist yet.Results:
dotnet build: 0 errors, 21 warnings, the same asmain.dotnet test: SimplePatch.Test 86/86, Swashbuckle.Test 17/17, OpenApi.Test 11/11. The machine has no .NET 8 runtime, so the net8.0 test projects ran withDOTNET_ROLL_FORWARD=Major.🤖 Generated with Claude Code