An analyzer can automatically detect issues with submissions and comment on them.
The C# analyzer implements the analyzer interface. It uses Roslyn to parse the submission's source code into syntax trees, which are then analyzed for known patterns.
To analyze a solution, follow these steps:
- Open a command prompt in the root directory.
- Run
./analyze.ps1 <exercise> <directory>
. This script will run the analyzer on the specified directory. - Once the script has completed, the analysis results will be written to
<directory>/analysis.json
.
To analyze multiple solutions at once, follow these steps:
- Open a command prompt in the root directory.
- Run
./bulk-analyze.ps1 <exercise> <directory>
. This script will run the analyzer on each directory sub-directory of<directory>
. - Once the script has completed, it will:
- Output general staticics to the console.
- Write detailed analysis results to
<directory>/bulk_analysis.json
.
To analyze a solution using a Docker container, follow these steps:
- Open a command prompt in the root directory.
- Run
./run-in-docker.ps1 <exercise> <directory>
. This script will:- Build the analyzer Docker image (if necessary).
- Run the analyzer Docker image (as a container), passing the specified
exercise
anddirectory
arguments.
- Once the script has completed, the analysis result can be found at
<directory>/analysis.json
.
Note that the Docker image is built using the .NET IL Linker, which is why building can be quite slow.
This repository uses the dotnet-format tool to format the source code. There are no custom rules; we just use the default formatting. You can format the code by running the ./format.ps1
command.
The scripts in this repository are written in PowerShell. As PowerShell is cross-platform nowadays, you can also install it on Linux and macOS.