Statica is a compilation-independent tool designed to detect static methods candidates in C# systems.
Before running Statica, you must install srcML and Stereocode:
- srcML: An infrastructure for the exploration, analysis, and manipulation of source code.
- Stereocode: A static analysis tool that detects and annotates class and function stereotypes using srcML input.
You will also need Python 3.12+ and a valid Google Gemini API Key.
-
Clone the Statica repository and navigate to the project root:
git clone https://github.com/KSU-SDML/Statica.git cd Statica -
Install the required Python packages:
pip install langgraph langchain-core langchain-google-genai google-genai pydantic
Statica relies on the Gemini API for evaluating external interface inheritance. You must provide a valid API key. You can set this as an environment variable prior to execution:
Linux/macOS:
export GOOGLE_API_KEY="your_api_key_here"Windows (Command Prompt):
set GOOGLE_API_KEY="your_api_key_here"(If the environment variable is not found during execution, Statica will securely prompt you to enter it in the terminal).
Running Statica is a two-step process. First, you must generate the required stereotype metadata, and then pass that metadata into the Statica pipeline.
Use srcML and Stereocode to process your target C# system. This will generate the *.metadata.csv file that Statica requires.
# Convert your source code into a srcML archive
srcml --position system.zip -o system.xml
# Run Stereocode to annotate stereotypes and generate the metadata CSV
stereocode system.xml -b -d -i -tPass the generated CSV file into statica.py.
python statica.py system.metadata.csv--output_file_path: Specify a custom name and path for the final Statica results. By default, it will save asoutput.csvin the root directory.
Example:
python statica.py Files-4.0.24.metadata.csv --output_file_path my_results.csvStatica will output a CSV file detailing the analysis of all non-degenerate and degenerate instance methods. The CSV contains the following columns:
- method_name: The name of the evaluated method.
- line_number: The line number where the method is defined.
- file_name: The source file containing the method.
- to_static: A boolean (
True/False) indicating if the method is safely eligible for static conversion. - reasoning: The pipeline stage or condition that led to the method's approval or rejection (e.g., Direct Analysis, Cascading Analysis, Cascading + LLM).