Repository navigation
Search an interface's ancestors breadth-first by inheritance distance [patch] - #180
Merged
Merged
Conversation
… [patch] TryFindMethod grouped an interface's inherited interfaces by how many interfaces each one itself inherits. A direct parent with no bases landed in the last group, behind interfaces further away, so IDerived : IBase, IX returned IRoot.Foo(int) two levels up instead of IX.Foo(). Adding a base to IX changed the answer. The levels are now built breadth-first: the direct interfaces of the type first, then their direct bases not yet visited, and so on. Fixes #178 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW4JrXevVTQZvqzLBX1
|
This was referenced Nov 13, 2026
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.



Fixes #178
What was wrong
SearchLevelsgrouped an interface's inherited interfaces byi.GetInterfaces().Length, which is how deep each interface's own ancestry runs, not how far it is fromtype. A direct parent with no bases ended up in the last group. SoIDerived : IBase, IXreturnedIRoot.Foo(int), two levels up, instead ofIX.Foo(). Adding a base toIXchanged the result.What changed
type's direct interfaces: the members ofGetInterfaces()that no other member of that set inherits. Each later level holds the direct bases of the previous level that haven't been visited yet.<remarks>onTryFindMethodnow describe the order breadth-first, matching the code.Tests
TryFindMethodPrefersDirectParentInterfaceOverMoreDistantOneis the repro from the issue.TryFindMethodInterfaceResultDoesNotChangeWhenAParentGainsABaseshows that adding a base to the sibling doesn't change which interface wins.TryFindMethodSearchesSharedInterfaceAncestorAtItsNearestDistancecovers a diamond.IDistanceRoot. With the fix, all 217 tests pass, and the Release build of every target framework is clean.Generated by Claude Code