- ExtractFirstScanner: reads-only scan of non-local/param read expressions
(member/field/property access, element access, invocation, cast), deduped
by symbol+text with occurrence counts; invocations flagged (hoisting
changes eval count); own-class field/property reads marked optional.
Assignment LHS skipped whole (decision 5) — surfaced as a report note.
- SignatureBuilder: promotes bucket overlaps into one coherent signature
(declared-inside vars drop from params; declared-inside return candidates
become the return; outside candidates already covered by their ref
write-back stay ref params). Trailing composite returns stay void with a
note suggesting an extract-variable first.
- ExtractionReporter + ReportFormatter: single composition shared by CLI and
tests; report = header, params (ref), returns, locals, extract-first
(count + flags), notes, suggested-signature line last.
- DataFlowClassifier: Returns now carry types (ReturnSuggestion) — the
signature line needs them.
- Displays: compact symbol/type formatting for the report.
- Fixture: RepeatReads (dedupe ×2 + skipped field write), Casts (cast
candidate) appended at the end so all pinned line numbers stay put.
- Tooling/DataFlowClassifier: buckets a resolved selection via Roslyn
DataFlowAnalysis. Selection flow + tail flow (statements AFTER the
selection in the same block) both use the two-argument AnalyzeDataFlow
overload on the contiguous run; the em 01 spike verdict is pinned in
tests — a synthetic BlockSyntax (parent decision #3) throws
ArgumentException "statements not within tree" and would re-bind
symbols, breaking the written-inside ∩ read-after identity match.
- Buckets per parent spec as plain-string records: in-params = local +
parameter reads (filtering the implicit `this`; fields/properties stay
in the em 03 extract-first bucket), ByRef = reassigned inside via a
non-declaration write (declaration initializers are not write-backs),
returns = written ∧ read-after (tail, branch-insensitive
over-approximation) + trailing `return X;` simple-name candidate,
locals = written ∧ never read-after.
- CLI now prints the raw bucket dump after the statement count line;
classification failures exit 1 with a clean message (exit 0/1/2
contract preserved).
- Tests: 6 new (in-param incl. `this` non-leak, multi-statement
two-argument path, trailing-return, ref-vs-in differential, extract-first
non-leak, synthetic-block dead path, single-statement one-argument path);
shared DemoFixture loader; fixed pre-existing CS8602 in DemoFixtureTests.
36/36 green.
- tools/ExtractMethod: net10.0 console app (Microsoft.CodeAnalysis.CSharp
5.9.0, pinned latest stable). CLI: <file.cs> <startLine> <endLine>.
Parses the file, builds a scratch compilation with refs from
TRUSTED_PLATFORM_ASSEMBLIES, and reports how many whole statements the
line range covers (clean error otherwise; exit codes: 0 ok, 1
resolution error, 2 usage).
- Tooling/CompilationLoader: shared parse + compilation path for CLI and
tests (tests exercise the exact loading path the CLI uses).
- Tooling/SelectionResolver: snaps a 1-based inclusive line range to
whole statements in the enclosing method body block; boundary checks
never split a statement; nested/blank-line ranges handled cleanly.
- tests/: ExtractMethod/Fixtures/Demo.cs checked-in fixture exercising
every bucket of the parent spec (read-only local, written+read-later
return, scratch local, param read, field+property access, indexer +
method invocation, multi-statement range incl. a for-loop); excluded
from project compilation, copied to output as data.
- Tests: Demo.cs compiles with no diagnostics; range 68..72 resolves to
2 statements (LocalDeclarationStatement, ForStatement); AnalyzeDataFlow
succeeds on the fixture's for-loop node; mid-statement range fails
cleanly. 30/30 green.