find_unused_symbols

[references]

Finds likely-unused source symbols with zero non-self references. Skips generated code, overrides/interface implementations, and reflection-sensitive symbols by default.

Try this tool in Playground.

Parameters

NameTypeRequiredDescription
kindsstringNoOptional kinds filter (comma-separated): 'Type,Method,Property,Field,Event'.
scopejsonNoOptional scope used to select symbol definitions to analyze.
accessibilitystringNoAccessibility filter. Default is 'Private,Internal'.
excludeReflectionSensitivebooleanNoSkip reflection- or activation-sensitive symbols. Default is true.
summaryOnlybooleanNoReturn grouped summaries without the paged symbol list. Default is false.
pathStylestringNoPath style: 'absolute' (default) or 'relative' (to solution root).
skipnumberNoPagination offset. Default is 0.
takenumberNoPagination size. Default is 200.

Examples

Find likely-unused private members

Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "find_unused_symbols",
    "arguments": {
      "accessibility": "Private,Internal"
    }
  }
}
Response
{
  "success": true,
  "data": {
    "totalCount": 2,
    "paging": {
      "skip": 0,
      "take": 200,
      "returned": 2,
      "total": 2
    },
    "items": [
      {
        "name": "BuildCache",
        "kind": "Field",
        "containingType": "SolutionManager",
        "symbolKey": "...",
        "filePath": "/path/to/SolutionManager.cs",
        "lineNumber": 18,
        "accessibility": "Private"
      }
    ],
    "summary": {
      "byKind": [
        {
          "key": "Field",
          "count": 1
        },
        {
          "key": "Method",
          "count": 1
        }
      ]
    }
  },
  "error": null
}

Summarize unused methods in one project

Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "find_unused_symbols",
    "arguments": {
      "kinds": "Method",
      "scope": {
        "mode": "project",
        "projectName": "MyProject"
      },
      "summaryOnly": true
    }
  }
}
Response
{
  "success": true,
  "data": {
    "totalCount": 2,
    "paging": {
      "skip": 0,
      "take": 200,
      "returned": 2,
      "total": 2
    },
    "items": [
      {
        "name": "BuildCache",
        "kind": "Field",
        "containingType": "SolutionManager",
        "symbolKey": "...",
        "filePath": "/path/to/SolutionManager.cs",
        "lineNumber": 18,
        "accessibility": "Private"
      }
    ],
    "summary": {
      "byKind": [
        {
          "key": "Field",
          "count": 1
        },
        {
          "key": "Method",
          "count": 1
        }
      ]
    }
  },
  "error": null
}

Response Notes

Returns likely-unused source symbols, optionally summarized by kind and project