accuracy(C#): measure import graph accuracy and close gaps below 90%
Part of #237.
Starting estimate: near 0% recall. This is an unmeasured guess.
Measure
Run codemap on real C# repositories at pinned commits and compare it to ground truth.
- Suggested ground truth: Roslyn or a symbol-reference sample.
- Report: recall, precision, and whether the coverage status was honest for each file.
Likely gaps to check
namespaces spanning files, global usings, partial classes.
Done when
- Repositories, commits, method and numbers are recorded here.
- Each miss has a root cause.
- Recall is at or above 90%, or the remaining gap is one codemap cannot close and its coverage status says so.
C#: file-to-file import graph measurement (#255)
Predictions below are predictions from a throwaway script, not measurements of a shipped resolver. Current-graph numbers are measured with codemap 4.6.3.
Repos (shallow clones)
- App-vNext/Polly @ 289f29808f70f49d3d46de57f42fcd1139bc2bd0 (802 C# source files)
- jbogard/MediatR @ 62010baf12851770553f275ce4047e93f4471e79 (159 C# source files)
Method
- Sample: 30 files per repo, seeded random sample (Python
random.Random(42).sampleover sorted tracked files; notshuf), tests included. - Ground truth G: NOT hand-built for all 300 files. G is a script-built proxy: explicit imports resolved to project files via a package/namespace/module index, plus same-package (C#: same and parent namespace, used namespaces; Elixir: alias-expanded dotted module references) type-name tokens in comment- and string-stripped code. I hand-checked 3 files (oban engine_bench.exs, MediatR Mediator.cs, cats FunctionK.scala) and they looked right; G may still contain token collisions (over-count) and miss top-level function use, macros, implicits (under-count). Treat G as a sample proxy.
- Current graph:
codemap --json --importers <T>for every G target and sample file plus 40 random files; an edge S->T counts as recovered if S is listed in importers(T)..codemap/config.jsononlylist includes the language extension in every repo (not hiding it). - (a) fully qualified import mapped to path by convention (Java/Kotlin/Scala
a.b.Ctoa/b/C.<ext>with prefix walk; C# namespace to directory suffix; ElixirFoo.BarBaztofoo/bar_baz.ex). - (b) Swift-style: any identifier (len>=3) in the file (import lines removed, comments and strings kept, as Swift does) equal to a type declared in another file, all declarers become targets. (b-uniq) same but only names declared in exactly one file.
- False edge = predicted edge not in G. Because G is a proxy, some false edges may be real and vice versa.
Current graph (measured)
| repo | files | G edges | current recovered | recall | partial on sampled files |
|---|---|---|---|---|---|
| c-polly | 802 | 203 | 0 | 0% | 30/30 |
| c-mediatr | 159 | 118 | 1 | 1% | 30/30 |
Precision of current edges: not measured (importers queries only reveal edges into queried files; every recovered edge I could see was in G). Honesty: coverage_status was partial with a symbol-imports note on 30 of 30 sampled files in every repo, so no sampled file claimed completeness.
Predicted recovery on the same sample (prediction)
| repo | G | (a) true | (a) recall | (a) false | (b) true | (b) recall | (b) false | (b) precision | (b-uniq) true | (b-uniq) recall | (b-uniq) false |
|---|---|---|---|---|---|---|---|---|---|---|---|
| c-polly | 203 | 1 | 0% | 62 | 203 | 100% | 393 | 34% | 43 | 21% | 74 |
| c-mediatr | 118 | 20 | 17% | 33 | 118 | 100% | 159 | 43% | 87 | 74% | 12 |
What blocks 90%
- C# graph is essentially empty: polly 0 of 203, mediatr 1 of 118.
- Blocker 1:
using X.Y;names a namespace spread across many files, never a file (convention (a) gave 1 true and 62 false in polly). Namespace to type-set index required. Medium. - Blocker 2: namespace hierarchy makes parent namespaces visible, and implicit/global usings (csproj ImplicitUsings,
global usingfiles) are not in the file. Medium. - Blocker 3:
partialclasses spread across files (Polly: Policy.*.cs); every declaring file is a true target, name index handles that if all declarers are added. - Name-only (b) hits 100% recall here (types are almost all same-namespace) but with 393 and 159 false edges; the proxy G counts same-namespace and using-namespace type mentions only. Unique-only recall 21% / 74%.
- 90% reachable: with namespace-scoped index. Fix size: medium.
Scripts:
Measured with codemap 4.6.3. Ground truth here is a script-built proxy with three files hand-checked. Predicted numbers are predictions, not measurements.