Repository navigation
Conversation
A struct reached by two routes is to be reported once where the validator can tell: a collection is enumerated once, and the properties that framework types declare on an item or root collection are not walked. Specs: a shared array, a list in a property and an item (still validated as an object), an ArraySegment, LinkedList and dictionary item, a root LinkedList, and an object outside an ArraySegment, which is no longer reached. Guards: a class object is reported once, a computed struct copy is still reported twice, and Tuple and KeyValuePair keep their walked properties. Rename StructItemsReportedTwiceTests to StructsReachedByTwoRoutesTests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
For a collection that is an item or the root object, the properties that framework types declare are no longer walked, as for a collection that a property holds. They repeat the items: ArraySegment.Array, LinkedList.First, Dictionary.Values. The rule lives in GetWalkedProperties, so IsLeafType agrees: int[] and ArraySegment<int> are now leaf types. The Array.SyncRoot special case is no longer needed. The walk remembers each collection it enumerated. A second route enumerates it again, so an item that a Validate method added is still found, but skips its struct items, which the first route reported. Class items were already dropped by reference. The spec for a list in a property and an item is renamed, because the list is enumerated twice; only its struct is reported once. Co-Authored-By: Claude Opus 5.5 <[email protected]>
README: a struct in a shared collection is reported once, and the properties that framework types declare on a collection item are not walked. Only a computed copy of a struct is still reported twice. Changelog: a BREAKING entry for the removed routes and the objects that only those routes reached, and a narrower struct known limit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
3 of 4 tasks
This branch has not been deployed
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
A struct has no identity, so the walk reported an invalid struct once for each route that reached it. The extra routes came from two sources. First, a collection that is an item or the root object had its framework properties walked, and those repeat the items: a
LinkedList<Line>item reported one struct four times, through[0],First.Value,First.ValueRefandFirst.List[0]. Second, a collection that two routes reach was enumerated once per route. The same collection held in a property already reported once, so an item and a property behaved differently. This is a 3.0 decision ("fix both causes"), because it changes the result list.Summary
GetWalkedPropertiesleaves out the properties thatSystem.*types declare, such asArraySegment<T>.Array,LinkedList<T>.FirstandDictionary<TKey, TValue>.Values. Properties that a user collection type adds, such asPagedList.Cursor, are still walked.IsLeafTypeuses the same method, soint[]andArraySegment<int>become leaf types. TheArray.SyncRootspecial case in the walk is gone.Validatemethod added in the meantime is still found, but skips its struct items. Class items were already dropped by reference. A first version enumerated each collection only once, and it brokeAn_item_that_adds_to_the_list_that_holds_it_does_not_make_enumeration_throw, so it was narrowed.ArraySegment, or a dictionary's comparer. A jaggedint[][]is no longer enumerated.StructItemsReportedTwiceTestsis nowStructsReachedByTwoRoutesTests. README and changelog are updated.Test plan
-p:IncludeNetFramework=true