RoslynSkills Research
Goal: combine text speed with Roslyn compiler truth (text first, semantic second, scoped diag third) via roscli (NativeAOT fast client) / roslynskills MCP + WorkspaceHost.
Channel & Tool Decision Rules
- Built-in
rg+read_file: Use for non-C# files (.md,.slnx,.csproj,.json), raw docs, and quick slices when no daemon is bound (~66–116 ms,0tax). Do not rely onrgfor overloaded/common C# symbols (Execute50Ktokens,Kind23Ktokens) or interface implementations/callers. roscli+WorkspaceHost+ Live Overlay Index (Preferred C# CLI lane): Bind once (roscli workspace.use MySolution.slnx --require-solution true [--wait-warmup true]), setROSCLI_DAEMON=required, and callroscli(%LOCALAPPDATA%\RoslynSkills\bin\roscli.exe,~54–71 mswarm, automatic fallback to managedroscli-slowwhen cold). Usectx.symbol_context --symbolfor 1-call symbol mindspace,ctx.search_text --syntax-filter code|declarations|invocationsfor zero-disk overlay search (beatsrgon selective tokens while dropping comment/string noise),ctx.read_windowfor zero-disk line windows +file_sha256,--symbol/--symbolsonnav.*/edit.*, and SHA-256 atomicedit.transaction/edit.batch_exact.RoslynSkills.McpServer --mode slim: Projects12descriptor-driven tools (includingroslyn_search+roslyn_context) at~6 KB(~1.5Ktokens/turn,93%smaller than--mode full's90.5 KB/61tools) over a persistentWorkspaceHostpipe (4.8–15.6 mswarm) with auto-bind on first semantic call and an inline parameter cheat-sheet inInitializeResult.instructions(no schema-read turn needed; passworkspace_pathin git worktrees).- External C# LSP (
csharp-ls,Roslyn LSP): Do not treat as equivalent toroscli:csharp-lsfails.NET 11ProjectReferences and emits false errors;Roslyn LSPanswers incomplete1match during async load,~515 mson refs,0interface callers (854z), and0items onworkspace/diagnostic.
What Roscli Is / Is Not
roscliis for in-repo semantic navigation, edits, diagnostics, and repair on C#/.NET source.roscliis not a package registry/API catalog/version-diff tool.- Use dotnet helper tools (for example
dotnet-inspect) for external package/framework API intelligence, then return torosclifor local code changes.
Session Start
Run command inventory first:
roscli list-commands --ids-only
roscli list-commands --stable-only --ids-only
roscli quickstart
If roscli is not on PATH, in this repository use:
scripts\roscli.cmd list-commands --ids-only
scripts\roscli.cmd list-commands --stable-only --ids-only
scripts\roscli.cmd quickstart
Cross-platform wrapper:
bash scripts/roscli list-commands --ids-only
bash scripts/roscli list-commands --stable-only --ids-only
bash scripts/roscli quickstart
Pit-of-success contract:
- Bind hot workspace once:
roscli workspace.use <solution.sln|.slnx> --require-solution true [--wait-warmup true](setROSCLI_DAEMON=required; stop only your own daemon withroscli daemon.stopat exit). - Discover:
list-commands --ids-only(70 commands:56stable /11advanced /3experimental) - Disambiguate args:
describe-command <command-id>(now emits full descriptor-driveninput_schema) - Start symbol reads with
ctx.symbol_context --symbol Type.Member(1-call mindspace: zero-disk def +file_sha256+ refs + interface callers + callees + impls + diag),ctx.search_text --syntax-filter code|declarations|invocations, andctx.read_window - Target directly via
--symbol Type.Memberonnav.*,edit.rename_symbol,edit.change_signature,nav.call_path(--source-symbol/--target-symbol), andanalyze.impact_slice; batch multi-symbol refs/invocations via--symbols A,B - Guard atomic multi-file writes with
edit.transaction/edit.batch_exact+expected_sha256/expected_file_hashes - Filter
ctx.file_outlinewith--member-name-contains <term> --max-members 20on large files (hot-routed viaroscliusing the cachedSyntaxTree) - Start stable-first: use
list-commands --stable-only --ids-only; only step intoadvanced/experimentalcommands when needed - Verify workspace binding: use
--workspace-path ... --require-workspace trueon project code - Prefer
.sln/.slnxfor repo-wide or hot-workspace context; use.csprojonly when intentionally project-scoped - Read payloads directly from top-level
Datain both daemon and in-process runs (Transport.modereportsdaemonvsin_process) - Verify before finalize: scoped
diag.get_workspace_snapshot --directory-path <dir> --brief true --include-diagnostics true --require-workspace true(~104–240 ms), thendotnet build/dotnet test
Cached invocation guidance (throughput vs freshness):
- For many Roslyn calls in one session, prefer published mode wrappers (
ROSCLI_USE_PUBLISHED=1) to reduce repeated CLI startup overhead. - After changing roscli source, refresh once (
ROSCLI_REFRESH_PUBLISHED=1) before the next run. - If debugging roscli behavior itself, prefer non-cached execution path for deterministic tool-dev feedback.
Mandatory policy: if you use non-Roslyn tooling to read/edit .cs, say so in your final report: RoslynSkills version (roscli --version), reason, missing command hypothesis, and expected impact.
Canonical Workflow (Find -> Edit -> Verify)
- Find declaration / references / interface callers directly via
--symbol(withWorkspaceHostbound):
roscli workspace.use MySolution.slnx --require-solution true
roscli nav.find_references --symbol MyNamespace.DeferredCatalogCommit.Kind --max-results 100
roscli nav.find_invocations --symbol MyNamespace.SchemaWriter.CreateTable --brief true --max-results 100
roscli nav.call_hierarchy --symbol MyNamespace.ComSqlDatabase.OpenSchemaWriter --direction incoming --max-depth 1 --brief true
Or anchor from a file when symbol path is unknown:
roscli nav.find_symbol src/MyFile.cs MySymbol --brief true --max-results 50 --workspace-path MySolution.slnx --require-workspace true
- Apply a structured edit:
roscli edit.rename_symbol src/MyFile.cs 42 17 NewName --apply true --max-diagnostics 50 --workspace-path MySolution.slnx --require-workspace true
- Verify folder/project compilation fast before running full test suites:
roscli diag.get_workspace_snapshot --directory-path src/MyProject --brief true --include-diagnostics true --require-workspace true
Investigative tracing (when target is unclear across many files):
roscli ctx.search_text "RemoteUserAction" src --mode literal --max-results 120 --brief true
roscli nav.find_invocations --symbol MyNamespace.MyType.Method --brief true --max-results 100
roscli nav.call_hierarchy --symbol MyNamespace.MyType.Method --direction both --max-depth 1 --brief true
roscli analyze.control_flow_graph src/MyFile.cs 42 17 --brief true --max-blocks 120 --max-edges 260 --workspace-path MySolution.slnx --require-workspace true
roscli analyze.dataflow_slice src/MyFile.cs 42 17 --brief true --max-symbols 120 --workspace-path MySolution.slnx --require-workspace true
roscli analyze.unused_private_symbols src --brief true --max-symbols 120
roscli analyze.dependency_violations src MyApp.Web MyApp.Application MyApp.Domain --direction toward_end --brief true
roscli analyze.impact_slice src/MyFile.cs 42 17 --brief true --include-callers true --include-callees true
roscli analyze.override_coverage src --coverage-threshold 0.6 --brief true
roscli analyze.async_risk_scan src --brief true --max-findings 120 --severity-filter warning --severity-filter info
Bundle multiple read-only probes in one call when useful (query.batch supports ctx.*, nav.* including nav.find_implementations and nav.find_overrides, analyze.*, diag.get_file_diagnostics, and diag.get_workspace_snapshot):
roscli run query.batch --input "{`"queries`":[{`"command_id`":`"ctx.search_text`",`"input`":{`"patterns`":[`"RemoteUserAction`",`"ReplicationUpdate`"],`"roots`":[`"src`"],`"mode`":`"literal`"}},{`"command_id`":`"nav.find_invocations`",`"input`":{`"file_path`":`"src/MyFile.cs`",`"line`":42,`"column`":17,`"brief`":true,`"workspace_path`":`"MySolution.slnx`",`"require_workspace`":true}}],`"continue_on_error`":true}"
Troubleshooting (Fast Fail-Closed)
- Args/schema error: run
roscli describe-command <command-id>once, fix args, retry. - Workspace is
ad_hocfor project code: rerun with explicit--workspace-path ... --require-workspace true. - Solution scope is expected but
resolved_workspace_pathis a project file: rerun with the.sln/.slnxpath. - You see
CS0518(missing core types): treat as invalid workspace binding and retry with correct workspace root.
Deep Reference (Progressive Disclosure)
Keep this SKILL.md small. Use these references only when needed:
references/diagnostics.md: workspace vs solution snapshots, common failure modesreferences/sessions.md: non-destructive sessions, apply-and-commitreferences/performance.md:roscli(NativeAOT) +WorkspaceHostdaemon,roscli-slowfallback, and published-mode knobs (ROSCLI_USE_PUBLISHED)references/dependency-intel.md: when to combine withdotnet-inspect

微信扫一扫