| Tool | Version | Purpose |
|---|---|---|
| .NET 8 SDK | 8.0+ | Build compiler + compile input C# projects |
| CMake | 3.20+ | Build runtime and generated C++ code |
| C++ compiler | C++20 | Compile runtime and generated code |
| Python | 3.8+ | Developer CLI tool (stdlib only) |
| Platform | Compiler | Minimum Version |
|---|---|---|
| Windows | MSVC 2022 | Visual Studio 17.0+ |
| Linux | GCC | 12+ |
| Linux | Clang | 15+ |
| macOS | Apple Clang | 14+ (Xcode 14+) |
Quick install:
python tools/dev.py setupauto-detects and installs
- OpenCppCoverage — C++ coverage (Windows)
winget install OpenCppCoverage.OpenCppCoverage
- ReportGenerator — Merged coverage HTML reports
dotnet tool install -g dotnet-reportgenerator-globaltool
- lcov + lcov_cobertura — C++ coverage (Linux, alternative to OpenCppCoverage)
# Configure
cmake -B build -S runtime
# Compile (Release + Debug)
cmake --build build --config Release
cmake --build build --config Debug
# Install to specified path
cmake --install build --config Release --prefix C:/cil2cpp
cmake --install build --config Debug --prefix C:/cil2cppBoehmGC is auto-downloaded via FetchContent, cached in
runtime/.deps/. Deletingbuild/won't re-download.
Shortcut: Steps 2-4 can be done in one step with
python tools/dev.py compile HelloWorld.
# Release (default)
dotnet run --project compiler/CIL2CPP.CLI -- codegen \
-i tests/HelloWorld/HelloWorld.csproj -o output
# Debug (#line directives + IL offset comments + stack traces)
dotnet run --project compiler/CIL2CPP.CLI -- codegen \
-i tests/HelloWorld/HelloWorld.csproj -o output -c Debug| Option | Description | Default |
|---|---|---|
-i, --input |
Input .csproj file (required) | — |
-o, --output |
Output directory (required) | — |
-c, --configuration |
Build configuration | Release |
cmake -B build_output -S output -DCMAKE_PREFIX_PATH=C:/cil2cpp
cmake --build build_output --config Release# Windows
build_output\Release\HelloWorld.exe
# Linux / macOS
./build_output/HelloWorld| File | Contents | Condition |
|---|---|---|
<Name>.h |
Struct declarations, method signatures, TypeInfo, static fields | Always |
<Name>_data.cpp |
TypeInfo definitions, VTable, string literals, P/Invoke | Always |
<Name>_methods_N.cpp |
Method implementations (partitioned by IR instruction count, ~20000/partition) | Always |
<Name>_stubs.cpp |
Default stubs for unimplemented methods | When stubs exist |
main.cpp |
Runtime init → entry method → runtime shutdown | Executable only |
CMakeLists.txt |
CMake configuration | Always |
stubbed_methods.txt |
Stub diagnostic report | When stubs exist |
| C# Project | Detection | Generated Result |
|---|---|---|
Has static void Main() |
Executable | main.cpp + add_executable |
| No entry point (library) | Static library | No main.cpp, add_library(STATIC) |
| Feature | Release | Debug |
|---|---|---|
#line directives (map back to C# source) |
— | Yes |
/* IL_XXXX */ offset comments |
— | Yes |
| PDB symbol reading | — | Yes |
| Runtime stack traces | Disabled | Windows: DbgHelp, POSIX: backtrace |
CIL2CPP_DEBUG define |
— | Yes |
| C++ optimization | MSVC: /O2, GCC: -O2 |
MSVC: /Zi /Od /RTC1, GCC: -g -O0 |
In Debug mode, when debugging with Visual Studio, #line directives make breakpoints and stepping navigate to original C# source files.
Python interactive CLI (stdlib only), unifying all build/test/coverage/code generation operations.
python tools/dev.py build # Compile compiler + runtime
python tools/dev.py build --compiler # Compiler only
python tools/dev.py build --runtime # Runtime only
python tools/dev.py test --all # Run all tests
python tools/dev.py test --compiler # Compiler tests only (xUnit)
python tools/dev.py test --runtime # Runtime tests only (GTest)
python tools/dev.py test --coverage # Tests + coverage HTML report
python tools/dev.py test --compiler --filter ILOpcode # Filter tests
python tools/dev.py install # Install runtime (Debug + Release)
python tools/dev.py codegen HelloWorld # Quick code generation test
python tools/dev.py compile HelloWorld # One-step compile: codegen → cmake → build
python tools/dev.py compile HelloWorld --run # Compile and run
python tools/dev.py compile -i myapp.csproj # Compile arbitrary project
python tools/dev.py integration # Integration tests (parallel, auto-detect workers)
python tools/dev.py integration -j 2 # 2 parallel workers
python tools/dev.py integration --sequential # Sequential mode
python tools/dev.py integration --filter Hello # Run only matching tests
python tools/dev.py setup # Check prerequisites + install optional depsRun without arguments for interactive menu:
python tools/dev.pypython tools/dev.py test --coverage
# 1. C# coverage (coverlet) — dotnet test --collect:"XPlat Code Coverage"
# 2. C++ coverage (OpenCppCoverage) — collect runtime test coverage
# 3. Merge two Cobertura XMLs → ReportGenerator → unified HTML report
# → Auto-opens browser to view report
# → Report path: CoverageResults/CoverageReport/index.htmlThe project has three layers of tests: compiler unit tests, runtime unit tests, and end-to-end integration tests.
dotnet test compiler/CIL2CPP.TestsFixture caching mechanism: SampleAssemblyFixture uses xUnit's ICollectionFixture<T> pattern — each sample's (HelloWorld, ArrayTest, FeatureTest, etc.) compilation result is created once and cached for the entire test run.
Important: When adding tests, you must use
GetXxxReleaseContext()/GetXxxReleaseModule()to access cached compilation results. Never directlynew AssemblySet()+new ReachabilityAnalyzer()in test methods (~12 seconds each).
cmake -B runtime/tests/build -S runtime/tests
cmake --build runtime/tests/build --config Debug
ctest --test-dir runtime/tests/build -C Debug --output-on-failureFull compilation pipeline: C# .csproj → codegen → CMake configure → C++ build → run → verify output. Covers 34 test projects including NuGet ecosystem validation, real project validation, and multi-package composition.
Data-driven test framework with parallel execution via ThreadPoolExecutor (auto-detect workers from CPU + available RAM; pre-builds CLI once then uses --no-build; ~6 min wall clock on 32-thread/64GB).
python tools/dev.py integration # parallel (default)
python tools/dev.py integration --sequential # sequential
python tools/dev.py integration -j 2 # 2 parallel workers
python tools/dev.py integration --filter HelloWorld # run matching tests# Recommended
python tools/dev.py test --all
# Or manually
dotnet test compiler/CIL2CPP.Tests
cmake --build runtime/tests/build --config Debug && ctest --test-dir runtime/tests/build -C Debug --output-on-failure
python tools/dev.py integration| Usage | Path | Description |
|---|---|---|
| All (dev + tests) | C:/cil2cpp |
cmake --install / dev.py compile/integration |
| Consumer | Custom | find_package(cil2cpp REQUIRED) → cil2cpp::runtime |