ArTchie Studios

Asmdef Cycle Detector

Finds directed cycles in .asmdef references and lists references that do not resolve to any known assembly definition.

Editor-only. Unity 2021.3+. Lives in Anvil.Editor (includePlatforms: Editor). No extra packages.

Editor window

ArTchie / Anvil / Asmdef Cycle Detector

Button What it does
Scan Walks .asmdef files under Assets/ (optional Packages/ for the cycle graph).
Copy JSON Puts the report JSON on the clipboard.
Write report Writes <project>/AnvilReports/asmdef-cycles.json (creates the folder if needed).

Toggle Include Packages/ in the cycle graph to treat package assemblies as nodes. Package .asmdef files are always indexed so a reference into Packages/ is not reported as missing.

Each cycle row is a closed name list (A → B → A). Missing references show the asmdef name, asset path, and the unresolved token.

Batchmode (CI)

Unity -batchmode -nographics -quit -projectPath <proj> -executeMethod Anvil.AsmdefCycleDetector.RunBatch -anvil-out <file.json> -anvil-fail
Arg Meaning
-anvil-out <file.json> Output path. Default: <project>/AnvilReports/asmdef-cycles.json
-anvil-fail Exit code 1 if any cycle was found; otherwise 0 (missing refs alone do not fail)
-anvil-packages Include Packages/ asmdefs in the cycle graph

RunBatch only calls EditorApplication.Exit when Application.isBatchMode is true. It logs count=, nodes=, missing=, and the output path.

Also accepts -anvil-out=file.json.

JSON

{
  "tool": "AsmdefCycleDetector",
  "generatedUtc": "2026-08-18T02:00:00Z",
  "count": 1,
  "nodes": 3,
  "items": [
    {
      "cycle": ["A", "B", "A"]
    }
  ],
  "missingReferences": [
    {
      "asmdef": "C",
      "assetPath": "Assets/C.asmdef",
      "reference": "DoesNotExist"
    }
  ]
}

count is the number of cycles. nodes is how many asmdefs were included in the graph. References may be assembly names, GUID:… strings, or small GUID/reference objects; GUIDs are resolved from the sibling .meta.

Notes

  • Empty projects (no .asmdef files) write count: 0, nodes: 0, empty arrays. A missing AnvilReports folder is created on write.
  • Self-loops and mutual references are cycles. Simple cycles are enumerated (capped at 128) and rotated so the lexicographically smallest name is first.
  • UnityEngine* / UnityEditor* names are treated as built-in and are not listed as missing.
  • Duplicate assembly names: the first file wins for name lookup.
  • Does not edit .asmdef files. Does not touch runtime player code.
  • Skips Library/.

Source in the box: Assets/ArTchie Studios/ArTchie-Suite/com.artchie.anvil/Documentation/AsmdefCycleDetector.md