Information Flow Analysis for C# — Understand What Your Code Really Does
SharpFocus is a Visual Studio Code extension that brings information-flow analysis to C#. Inspired by Flowistry for Rust, it uses program slicing to help developers understand data dependencies and code relationships at a glance.
SharpFocus implements program slicing — a static analysis technique that answers two critical questions about any variable in your code:
- Backward Slice: What code could have influenced this variable?
- Forward Slice: What code could be influenced by this variable?
By combining both directions, SharpFocus creates a focus mode that highlights only the relevant code paths, fading everything else away. Perfect for debugging, refactoring, and code review.
Click any variable, parameter, or field and see the complete dataflow instantly. Everything else fades away.
Normal Mode
Advanced Mode - Detailed flow indicators with colored relations and gutter icons:
Navigate through your code's dataflow with keyboard shortcuts and visual aids:
- Tree view with hierarchical flow visualization
- CodeLens annotations at each step
- Quick pick menu for flow details
- Keyboard shortcuts: Ctrl+Alt+N (next) / Ctrl+Alt+P (previous)
Tree View shows all flow locations organized by type:
Complete View with both code highlighting and tree navigation:
Normal Mode with Tree for a cleaner look:
- Analysis Mode: Focus on click, or manual trigger
- Display Mode: Normal (minimalist) or Advanced (detailed)
- Server Path: Custom language server location
- Trace Level: Debugging and diagnostics
- UI Options: Disable word highlighting to avoid conflicts
Download the latest release from Releases and install via:
- Open a C# project in VS Code
- Click on any variable or parameter
- Watch SharpFocus highlight the complete dataflow
- Use Ctrl+Alt+N / Cmd+Alt+N to navigate through flow locations
That's it! No configuration needed for basic usage.
SharpFocus consists of three main components:
Core abstractions, data models, and interfaces:
- Flow domain and slice computation models
- Analysis request/response contracts
- Immutable data structures with builder patterns
Roslyn-based static analysis engine:
- Control-flow graph (CFG) construction
- Dataflow analysis and abstract interpretation
- Alias analysis and mutation detection
- Forward/backward slice computation
- Caching and performance optimization
LSP-compliant language server using OmniSharp extensions:
- Request handling and orchestration
- Workspace management
- Diagnostics and error handling
- Logging and observability
TypeScript-based VS Code client:
- LSP client integration
- UI rendering (decorations, CodeLens, tree view)
- Navigation and command handling
- Settings and configuration
- .NET 10.0 SDK (preview) or .NET 8.0+
- Node.js 20+ and npm
- VS Code 1.80.0+
- Open the repository in VS Code
- Press F5 to launch Extension Development Host
- Open a C# project in the new window
- Test Focus Mode on C# files
- Focus Mode with forward/backward slicing
- Normal and Advanced display modes
- Tree view and CodeLens integration
- Intra-method analysis
- Cross-method analysis - Slice across method boundaries
- Property and field analysis - Track through getters/setters
- Async/await support - Handle Task-based flows
- LINQ query analysis - Track through query expressions
- Performance improvements - Large solution optimization
- Configuration UI - Visual settings editor
See ROADMAP.md for details.
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome!
- Cross-method analysis implementation
- Performance optimization
- Additional display modes
- Documentation improvements
- Bug fixes and testing
Made with ❤️ for C# developers who want to understand their code better
Please ⭐this repo if you find it useful!
.png)









