C# Dependency Analysis

builds XML Document

1.0 Concept

Static type-based analysis of file dependencies for all C# files in a specified directory tree.

2.0 Overview

The analyzer runs two passes over a directory tree of C# source files:
  1. Type Analysis — parses files to build a type table of all defined namespaces, classes, structs, interfaces, enums, and delegates.
  2. Dependency Analysis — parses files again to find type usages (declarations, parameters, inheritance) and maps each file to the files it depends on.
A dependency graph is then built from the dependency table and analyzed for strong components (cycles) using Tarjan's algorithm.

3.0 Packages

PackageDescription
DemoExecutiveEntry point; orchestrates type analysis, dependency analysis, graph construction, and strong component detection
ParserRule-based parser pipeline: applies rules to semi-expressions and fires actions
SemiExpSemi-expression collector; groups tokens into meaningful statement units
TokerTokenizer; breaks source text into tokens
TypeTableStores type definitions found during Pass 1
DependencyTableStores per-file dependency lists built during Pass 2
ElementElem struct holding type category, name, file, and namespace
FileMgrDirectory tree navigator; collects files matching a pattern
CsGraphGeneric directed graph with strong-component (Tarjan) analysis
DisplayFormatted console output helpers

4.0 Usage

dotnet run --project DemoExecutive/DemoExecutive.csproj <path> <pattern>
Example (analyze the project itself):
dotnet run --project DemoExecutive/DemoExecutive.csproj ../../../ *.cs

5.0 Build

Requires .NET 10.0 SDK.
dotnet build DemoExecutive/DemoExecutive.csproj