Browse Source

Search: <angle brackets> opt in to private/compiler-generated entities

The default ApiVisibility=PublicOnly setting filters search results
through CheckVisibility, which rejects private entities. Compiler-
generated names — async/iterator state machines (<Method>d__N),
display classes (<>c__DisplayClass), anonymous-method closures (<>c)
— are all private, so they were unfindable even when the user
typed the exact full name.

Assisted-by: Claude:claude-opus-4-7:Claude Code
pull/3755/head
Siegfried Pammer 2 months ago
parent
commit
2510e70fc6
  1. 7
      ICSharpCode.ILSpyX/Search/AbstractEntitySearchStrategy.cs
  2. 8
      ICSharpCode.ILSpyX/Search/AbstractSearchStrategy.cs
  3. 7
      ILSpy/Search/RunningSearch.cs

7
ICSharpCode.ILSpyX/Search/AbstractEntitySearchStrategy.cs

@ -43,6 +43,13 @@ namespace ICSharpCode.ILSpyX.Search @@ -43,6 +43,13 @@ namespace ICSharpCode.ILSpyX.Search
if (apiVisibility == ApiVisibility.All)
return true;
// The query parser sets IncludePrivateApi when the user types `<` or `>` —
// characteristic of compiler-generated names (state-machines, display classes,
// anonymous closures). Bypass the public-only filter so those names actually
// surface as results when the user is hunting for them specifically.
if (searchRequest.IncludePrivateApi)
return true;
while (entity != null)
{
if (apiVisibility == ApiVisibility.PublicOnly)

8
ICSharpCode.ILSpyX/Search/AbstractSearchStrategy.cs

@ -55,6 +55,14 @@ namespace ICSharpCode.ILSpyX.Search @@ -55,6 +55,14 @@ namespace ICSharpCode.ILSpyX.Search
public Regex? RegEx;
public bool FullNameSearch;
public bool OmitGenerics;
// When set, CheckVisibility bypasses the api-visibility filter so private /
// compiler-generated entities (state-machines, display classes, anonymous
// closures — anything with `<...>` segments in its metadata name) become
// findable. Set by the query parser when the user types `<` or `>` in
// their search term: those characters are characteristically present in
// compiler-generated names and rare in everyday API names, so they're a
// reliable signal that the user wants the visibility filter relaxed.
public bool IncludePrivateApi;
public string InNamespace;
public string InAssembly;
}

7
ILSpy/Search/RunningSearch.cs

@ -337,6 +337,13 @@ namespace ILSpy.Search @@ -337,6 +337,13 @@ namespace ILSpy.Search
}
if (!(term.Contains('<') || term.Contains('`')))
request.OmitGenerics = true;
// Angle brackets are characteristic of compiler-generated names
// (`<X>d__N`, `<>c__DisplayClass`, etc.) and rare in everyday API
// names — treat them as the user opting in to private /
// compiler-generated entities even when the global visibility
// setting is PublicOnly.
if (term.Contains('<') || term.Contains('>'))
request.IncludePrivateApi = true;
switch (prefix?.ToUpperInvariant())
{

Loading…
Cancel
Save