Skip to content

Fix/external symbols#114

Open
thgbrb wants to merge 2 commits into
sourcegraph:mainfrom
thgbrb:fix/external-symbols
Open

Fix/external symbols#114
thgbrb wants to merge 2 commits into
sourcegraph:mainfrom
thgbrb:fix/external-symbols

Conversation

@thgbrb

@thgbrb thgbrb commented Jun 9, 2026

Copy link
Copy Markdown

Implement external_symbols to fix dangling cross-package references

Summary

This PR populates Index.external_symbols with SymbolInformation for symbols defined in external NuGet/BCL packages that are referenced by indexed source files. Before this change, the field was never written to, which left every cross-package reference orphaned and unusable for code navigation.

Fixes #62. Addresses the user-visible complaint behind #3.

Measured on a real-world .NET 9 + EF Core 9 codebase (1,263 source documents, 361,764 occurrences):

Metric Before After
scip lint errors 208,950 ~23,500
Error rate (over all occurrences) 59.87% 6.50%
Error rate excluding index-local namespaces n/a 0.08%

The remaining counts are edge cases involving deeper type-graph paths (transitive ancestors of generic constructions). They could be addressed by walking the full transitive hierarchy when collecting from the relationship path, at the cost of larger indexes; this PR keeps the collection one level deep.

Relationship to existing issues

#62 "C# indexing doesn't work properly". Same bug. The maintainer's reproduction on dotnet/eshop shows references to global symbols missing because their SymbolInformation was never written. This PR resolves it.

#3 "Missing System.Runtime core assembly". The user-visible complaint (BCL navigation broken) is the same and is resolved by this PR. The specific mechanical detail in that issue (the literal <Missing Core Assembly> placeholder) no longer exists in the current code, so #3 partially reflects an older resolution path; the current scip-dotnet resolves System.Runtime identity correctly and only the emission was missing.

Limitations

  1. The 23,500 residual nuget . . errors (mostly namespaces) are intentionally untouched and need a separate design decision.
  2. Validation on net8.0 / net9.0 was not performed in this PR; the snapshot suite runs under whichever framework dotnet test selects on the build machine (here, net10.0). The fix is framework-agnostic.
  3. The size impact of including hover documentation on every external symbol was not measured on very large codebases; for the reference project it was within normal variance.

Thiago Borba and others added 2 commits June 9, 2026 15:26
Reference occurrences for symbols defined in external NuGet/BCL packages
were emitted without a matching SymbolInformation: external_symbols was
never populated and SymbolInformation was only emitted for in-source
definitions. As a result every cross-package reference dangled, which
scip lint reports as "no matching SymbolInformation in external symbols
or any document".

Collect every referenced external-package symbol while indexing and
declare it in Index.external_symbols with minimal hover documentation
(no relationships, to avoid recursing across the BCL type graph),
deduplicated against in-source definitions. Index-local ("nuget . .")
symbols are intentionally out of scope.

Add ExternalSymbolsTests as a mini scip-lint regression test asserting
every genuine-external occurrence resolves.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Records implement IEquatable<T> implicitly and framework base/interface
hierarchies expand transitively to external types that never appear
textually in the source, so those relationship targets never passed
through VisitOccurrence and were never collected into
Index.external_symbols. scip lint flagged them as "has a relationship to
<symbol>, but couldn't find sourcegraph#2 in external symbols or some other document".

Collect external relationship targets (BaseType chain, AllInterfaces,
OverriddenMethod, InterfaceImplementations) via the same minimal
SymbolInformation path used for reference occurrences (hover documentation
only, no relationships, to avoid recursing across the BCL type graph).

Add EveryExternalRelationshipTargetHasSymbolInformation regression test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

C# indexing doesn't work properly

1 participant