Fuse
Concepts

Roslyn structural analysis vs regex

What Roslyn provides by default for C# structure and what regex still handles.

Fuse analyzes C# in two layers. Roslyn parses each .cs file and drives every structural capability: indexing the semantic graph, skeletons, dependency edges, type location, symbol slicing, route maps, and semantic markers. Regex still handles C# content reduction (comment and using removal, whitespace compression), the solution and project reference graph (.sln and .csproj text), and cross-codebase pattern detection. This page explains the split and what each layer is good at.

Roslyn: Default Structural Analysis

Roslyn is mandatory for C# structural work. There is no flag to disable it and no regex fallback for indexing, skeleton, dependency, route-map, or semantic-marker extraction. When a project does not load through MSBuild, Fuse falls back to syntax-only indexing for that project, which still uses the Roslyn parse tree but resolves fewer cross-project edges.

The Roslyn extractors work from the parsed syntax tree rather than line-based regex, so conditional compilation, partial classes, and braces inside strings no longer desynchronize the skeleton extractor, and the dependency extractor captures references regex would miss, such as return types, generics, and object creations. The analysis is syntax-level, not full semantic binding: it identifies type-position identifiers without resolving them across a compilation, so it is more accurate than regex but not a guaranteed-complete call graph.

On the benchmark corpus, the Roslyn skeleton keeps method signatures the old regex skeleton dropped on hard codebases. Newtonsoft.Json is the headline case: regex skeleton kept 4 percent of method signatures; Roslyn keeps 100 percent:

RepoRegex skeleton (historical)Roslyn skeleton
MediatRtypes 100%, methods 84%types 100%, methods 100%
FluentValidationtypes 98%, methods 99%types 100%, methods 100%
AutoMappertypes 91%, methods 86%types 99%, methods 100%
Newtonsoft.Jsontypes 71%, methods 4%types 100%, methods 100%

Higher fidelity means larger skeleton output on complex code, because the regex skeleton's deep cut was partly a fidelity failure, not real saving. Newtonsoft.Json moves from 96,953 tokens (regex, 93.4 percent reduction but 4 percent method fidelity) to 694,862 tokens (Roslyn, 52.7 percent reduction at 100 percent fidelity). Roslyn does not weaken fidelity to inflate reduction; it gives a faithful signatures-only cut.

Roslyn also powers symbol-level scoping: a Type.Member seed scopes its file to that one member, keeping its body in full and reducing every other member to its signature. A context plan can emit a thin host-type skeleton with the relevant members in full and the rest collapsed to signatures, using exact member boundaries from the parse tree.

Regex: Reduction, Project Graph, and Patterns

Regex remains the right tool where a full parse is unnecessary or the input is not C# source.

AreaMechanismExamples
C# content reductionLexer and regex transforms in CSharpReducerComment removal, using stripping, aggressive compression
Project graphRegex over .sln and .csproj textSolution entries, ProjectReference edges
Pattern detectorsRegex and heuristics over fused contentDI registration, CQRS, repository conventions
Secret redactionRegex plus entropy heuristicsAPI keys, connection strings

The project graph is best-effort: references injected through imported targets, MSBuild variables, or globbing are not resolved. Pattern detectors name conventions; they do not perform semantic analysis.

Next

See Scoping for the modes Roslyn sharpens, Scoping internals for graph and index detail, or the measured fidelity in Benchmarks.

On this page