Repository navigation
Walk public instance properties only, not static ones - #88
Merged
Merged
Conversation
tgharold
force-pushed
the
tgh-20261002-nested-class-level-error-path
branch
from
October 2, 2026 20:56
f7f755e to
7d4e840
Compare
Base automatically changed from
tgh-20261002-nested-class-level-error-path
to
master
October 2, 2026 20:59
A static property holds data of the type, not of the model, and Validator, MVC and System.Text.Json ignore it. The walk read it because Type.GetProperties() with no arguments returns static properties too, so a shared invalid static object failed every model of that type. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both the walk and the leaf type check now ask for public instance properties. A static property is no longer walked, so a shared invalid static object no longer fails every model of its type, and a static property that builds a new object on each read no longer needs the Equals check to stop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tgharold
force-pushed
the
tgh-20261002-instance-properties-only
branch
from
October 2, 2026 21:00
26da9ea to
be883a3
Compare
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.
Motivation
The validator walked public static properties as well as instance properties, because
Type.GetProperties()with no arguments returns both. A static property holds data of the type, not of the model.Validatorignores it, and so does System.Text.Json. The effect was that a shared static object that was invalid failed every model of that type, with an error such asShared.Name, and a static property that builds a new object on each read needed the equal-ancestor check or the depth limit to stop the walk.Walking public instance properties only matches what a caller expects from DataAnnotations. It changes results, because a model that failed only because of a static property now passes, so it is marked BREAKING in the changelog.
This is part 3 of 3 small PRs, in this order: root collection (#86), nested class-level error path (#87), instance properties only (this one). This PR is stacked on #87 and targets its branch, so the diff shows only this change. Merge #86 and #87 first. After #87 merges, GitHub retargets this PR to master.
Summary
GetWalkedProperties, which asks for public instance properties and applies the existing walk rules. The walk and the leaf-type check both use it, so they agree.Test plan
-p:IncludeNetFramework=true)