Fix #3797: resolve ilspycmd -t type names with fuzzy matching - #3801
Merged
Conversation
--list-* printed generic types without their `n arity suffix, yet -t only
accepted the exact reflection name, so a name copied straight from the listing
threw "Could not find type definition". The listing now prints the reflection
name, and -t resolves through a ladder of progressively looser, uniqueness-
checked rules: the engine's exact lookup, an arity- and nesting-separator-
insensitive FullName match, a case-insensitive match, a namespace-less simple
name, and a trailing segment path ("Dictionary.KeyCollection"). The input is
parsed with System.Reflection.Metadata.TypeName and reduced to its underlying
definition first, so assembly qualification, generic arguments, and
array/pointer/byref decorations cannot corrupt the comparison key. An ambiguous
name reports its candidates instead of guessing, and a miss prints name
suggestions and returns EX_DATAERR rather than dumping a stack trace.
Assisted-by: Claude:claude-opus-4-8:Claude Code
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 #3797.
--list-*printed generic types without their`narity suffix, but-tonly accepted the exact reflection name. So a type name copied straight from the listing (e.g.JetBrains.ReSharper.Psi.CachedPsiValue) threwCould not find type definitionand the user had to know to append`1by hand.Changes
FullTypeName.ReflectionName, so the names it emits are directly usable with-t.-tresolution goes through a ladder of progressively looser, uniqueness-checked rules:Ns.List`1);FullNamematch (Ns.List,Ns.A`1+B`2);FullNamematch;List);Dictionary.KeyCollection→...Generic.Dictionary`2+KeyCollection, matched on whole.-separated segments soReadOnlyDictionary.KeyCollectionis not a false hit).System.Reflection.Metadata.TypeNameand reduced to its underlying definition first, so assembly qualification, generic arguments, and array/pointer/byref decorations cannot corrupt the comparison key.EX_DATAERRinstead of dumping a stack trace.Verified
Built and run against
System.Private.CoreLib.dll,ICSharpCode.Decompiler.dll, and a purpose-built nested-generic assembly:-t Ns.EmptyList(arity-stripped) and-t EmptyList(simple) resolve the generic type.-t Dictionary.KeyCollectionresolves the nested type;-t ReadOnlyDictionary.KeyCollectionresolves its own distinct type.List`1[[System.String, ...]]), assembly-qualified, array (List`1[]) and byref forms all reduce to the type definition.-t KeyCollectionreports the ambiguity with candidates; an unknown name returns exit code 65 with suggestions.This PR description was written by an AI agent (Claude, claude-opus-4-8, via Claude Code).