Get Compiler Diagnostics
get_diagnosticsCompile all C# projects in the session in memory to get compiler errors and warnings without a build. Call refresh_session after editing .cs files, then run this to check the updated snapshot.
Instructions
Compiler errors and warnings without a build: every C# project of the session is compiled in memory, in seconds. For design findings: list_insights.
Use it after editing .cs files: refresh_session, THEN this - it compiles the session's snapshot, not the disk (an answer known to be behind it: verdict:'stale'). After a build call refresh_session(force: true); a restore needs no force.
Returns verdict (when stale or inconclusive), projectsScanned, errorCount, warningCount, infoCount and diagnostics: at most 200 items (counts cover all; see severityFloor). A multi-targeted project reports a diagnostic once; #pragma-suppressed ones are excluded. No analyzer runs, not even the SDK's; source generators that load do run.
Disclosures:
incompleteProjects, incompleteRatio, suppressedDiagnosticsTotal: projects whose core references did not resolve (an entry's cause names the remedy). Their diagnostics are counted, not listed; that total is a MAGNITUDE, not a ratio with errorCount. verdict:'inconclusive' + reliable:false: most projects are incomplete.
projectsWithoutCode: unresolved, no code, not counted.
unrestoredProjects (missingTarget, restoreCommand): restore output does not serve them.
referencedProjectsWithoutCode: resolved, compiled empty; dependents' diagnostics counted.
cascadeFromIncomplete:true on an item: inherited from an incomplete one.
generatedCodeGaps: source-generator or WPF markup-compiler output is missing.
unloadedProjectReferences (an unbuilt F#/VB or a C++ reference), resourcesWithoutGeneratedClass, languageVersionGap (a compiler older than the code).
designTimeBuildFailures: MSBuild failed or warned loading a project (options may be incomplete).
suppressors: references whose DiagnosticSuppressors a real build runs (runSuppressors).
projectsNotBuiltBySolution: counted errors a solution build never reports (item: notBuiltBySolution).
Needs a live session; writes nothing.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"sessionId": "<sessionId>"
},
"name": "get_diagnostics"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| scope | No | 'solution' (default) or a file-path substring (e.g. 'MyApp.Core' or 'Settings.cs') that filters the RESULT. It is matched against a diagnostic's location as the answer prints it, so a directory separator is a backslash on Windows. It does not reduce the work: all projects are compiled either way - it saves response tokens, not latency. | solution |
| sessionId | Yes | The session_id returned by analyze_solution. Also takes an absolute .sln/.slnx/.slnf path, analyzed on first use. | |
| severityFloor | No | Minimum severity to include: 'auto' (default), 'error', 'warning', 'info', or 'hidden'. 'auto' counts warnings as 'warning' does, but when the compile has errors it lists only the errors (warningsNotListed says how many warnings it left out of the list); 'warning' lists both. The answer's severityFloor names the floor the counts used, so 'auto' answers 'warning'; warningsNotListed stands wherever 'auto' listed less. | auto |
| runSuppressors | No | Run the DiagnosticSuppressors the projects' analyzer references declare, as a real build does, so a diagnostic they suppress is not counted. Off by default: a suppressor is code of the analyzed solution and runs inside this server (see SECURITY.md); the answer's suppressors member says where it would matter. |