Find Calls to External APIs
calls_externalFind code calling external BCL or package members by pattern to assess AOT/trimming readiness, security surface, and dependency footprint.
Instructions
Find the code that calls an EXTERNAL member - BCL or package - whose key contains a pattern. find_usages answers for solution symbols only; find_by_side_effects classifies the same calls into effect tokens.
Use it for 'who calls the risky or external API X?': AOT and trimming readiness, security surface, dependency footprint (pattern 'Process.Start', 'Assembly.Load', 'DateTime.UtcNow').
Returns scope, pattern, methodsScanned, matches - a capped envelope of at most 200 hits, sorted by type and name, not ranked - and testMatchesFiltered when the test filter removed hits. A hit carries name, declaringType, namespace, matchedCalls (invoked methods and method groups, keys like 'System.IO.File.ReadAllText(string)') and matchedReads (external properties read or written, like 'System.DateTime.UtcNow'). The units scanned are methods plus every accessor and constructor with a body, under their metadata names (get_X, set_X, .ctor); an initializer counts toward the constructor that runs it.
The pattern is a case-insensitive substring of the whole key, parameter list included, so a type name also hits the units that only pass that type to another API. It is an open vocabulary: there is no did-you-mean, and empty is now a strong statement, though not absolute. Not recorded: an external field read ('string.Empty'), a bare 'new X()', operators and conversions, indexers, event subscriptions and compiler-lowered calls (using, foreach, await). Cross-check a surprising empty against the declaring type ('DateTime' instead of 'DateTime.UtcNow'). A 'note' leads the answer when it is empty - it says when only the test filter emptied it - and when a project's core references did not resolve: an unresolved call records no key.
Read-only; works on a recalled session. Test-project code is excluded by default; includeTests=true includes it. testMatchesFiltered counts the filtered-out units, which methodsScanned does not include. scope is 'solution' or a namespace prefix, matched case-insensitively on segment boundaries.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| scope | No | 'solution' (default) or a namespace prefix (e.g. 'MyApp.Infrastructure') to narrow scope. | solution |
| pattern | Yes | A substring of the external (BCL/third-party) call key to match (case-insensitive), e.g. 'Process.Start', 'File.', 'Assembly.Load', 'System.Reflection', 'JsonSerializer'. Required - a very broad pattern (e.g. 'System') truncates at 200. | |
| sessionId | Yes | The session_id returned by analyze_solution. Also takes an absolute .sln/.slnx/.slnf path, analyzed on first use. | |
| includeTests | No | Include test-project methods (default false - production focus; test setup/assertions calling external APIs would otherwise drown the signal). |