SharpFocus is a Visual Studio Code extension that revolutionizes understanding of C# code through information flow analysis. It employs program slicing to reveal data dependencies and code interactions, simplifying debugging, refactoring, and code reviews. Experience streamlined navigation and focus on relevant code paths to improve development efficiency.
SharpFocus is a powerful Visual Studio Code extension designed to enhance C# development by providing information-flow analysis capabilities. It is inspired by the Rust project Flowistry and offers an intuitive way for developers to understand the intricate data dependencies and relationships within their code.
Key Features
Information Flow Analysis
SharpFocus employs static analysis techniques known as program slicing to address two essential questions related to variables in your code:
- Backward Slice: Identifies the code that may have influenced a particular variable.
- Forward Slice: Reveals the code that could be influenced by this variable.
By combining the results from both directions, SharpFocus enables a focus mode that highlights relevant code paths while obscuring unrelated sections, making it an invaluable tool for debugging, refactoring, and code reviews.
Focus Mode
Interactively click on any variable, parameter, or field to see its entire dataflow immediately. In this mode, all extraneous information fades away, allowing for pinpoint accuracy in analyzing code.
Navigation Tools
Effortlessly navigate through code with the following features:
- Tree View: Organized visualization of flow locations by type.
- CodeLens Annotations: Displays flow indicators at each step of the process.
- Keyboard Shortcuts: Quickly move through flow details with
Ctrl+Alt+Nfor next andCtrl+Alt+Pfor previous.
Adjustable Settings
Customize SharpFocus to fit specific coding preferences:
- Choose between focus on click or manual analysis triggers.
- Select display modes: Normal for simplicity or Advanced for detailed flow indicators.
- Adjust server path, trace level, and UI options to optimize the user experience.
Use Cases
SharpFocus can effectively assist in various scenarios:
- Debugging Null References: Quickly identify possible null assignments by clicking on relevant variables.
- Refactoring Impact Analysis: Determine the usage of variables before making changes to ensure safe code updates.
- Code Review Efficiency: Streamline code reviews by focusing directly on impactful dataflows, minimizing distractions.
Architecture Overview
SharpFocus is composed of several essential components to ensure robust functionality:
- SharpFocus.Core: Contains core abstractions, models, and interfaces for flow computation.
- SharpFocus.Analysis: Utilizes the Roslyn engine for static analysis, including control-flow and dataflow analysis.
- SharpFocus.LanguageServer: Manages the language server capabilities compliant with LSP frameworks.
- VS Code Extension: The TypeScript client integrates with VS Code to facilitate user interaction and settings management.
Development and Contribution
Contributions to SharpFocus are highly encouraged, with opportunities to enhance cross-method analysis, optimize performance, add new display modes, and improve documentation. Interested developers should refer to the contributions section in the repository for details on how to get involved.
SharpFocus is dedicated to helping C# developers grasp the complex flows within their code, fostering a deeper understanding and more effective programming practices.
No comments yet.
Sign in to be the first to comment.