Get Compiler Diagnostics
get_diagnosticsCompiles every C# project in the session in memory to return compiler errors, warnings, and info without a build. Use it after editing .cs files to check diagnostics.
Instructions
Compiler errors and warnings without a build: every C# project of the session is compiled in memory, in seconds. list_insights reports design findings instead.
Use it after editing .cs files: refresh_session, THEN this - the diagnostics come from the session's snapshot, not from disk, and an answer known to be behind the disk leads with verdict:'stale'. After a build call refresh_session(force: true); a restore needs no force.
Returns verdict (only when stale or inconclusive), projectsScanned, errorCount, warningCount, infoCount and diagnostics: at most 200 items (id, severity, message, location, category, project), while the counts cover the full set; with errors, the default lists only them (warningsNotListed). A multi-targeted project reports a diagnostic once; #pragma-suppressed ones are excluded. No analyzer runs, the SDK's included; source generators that load do run.
Disclosures say what the counts leave out:
incompleteProjects, incompleteRatio, suppressedDiagnosticsTotal: projects whose core references did not resolve (e.g. no targeting pack). Their diagnostics are counted, not listed. Read that total as a MAGNITUDE, not as one half of a ratio with errorCount. verdict:'inconclusive' + reliable:false fire only when a strict majority of projects is incomplete.
cascadeFromIncomplete:true on an item: inherited from an incomplete project.
generatedCodeGaps: code a source generator or the WPF markup compiler writes is missing.
designTimeBuildFailures: MSBuild reported a failure loading a project (a warning reads alike); its compiler options may be incomplete.
suppressors: references whose DiagnosticSuppressors a real build runs (see runSuppressors).
Needs a live session (a recalled one is rejected); writes nothing. scope: 'solution' or a case-insensitive substring of an item's location - for a file under the solution folder its relative path, with the OS separator (backslash on Windows). It filters the ANSWER, not the work: every project is compiled either way.
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 (see the tool description) - 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. | 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. |