# cpp-orchestrator **Repository Path**: suyuexinghen28/cpp-orchestrator ## Basic Information - **Project Name**: cpp-orchestrator - **Description**: A comprehensive, production-ready system for converting C# codebases to idiomatic, performant C++ code. - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-10-19 - **Last Updated**: 2025-10-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # C# to C++ Conversion System A comprehensive, production-ready system for converting C# codebases to idiomatic, performant C++ code. ## Overview This project provides an automated conversion pipeline that transforms C# source code into equivalent C++ code, complete with a runtime compatibility layer that mimics .NET Base Class Library (BCL) functionality. ### Key Features - **Deep Semantic Analysis**: Roslyn-based C# analysis for accurate type and dependency resolution - **Intelligent Transformation**: Rule-based conversion engine with customizable transformation patterns - **Runtime Compatibility**: Comprehensive C++ shim library providing .NET-like APIs - **Modern C++**: Generates idiomatic C++20 code with contemporary best practices - **Cross-Platform**: Supports Windows, Linux, and macOS targets - **Production Ready**: Comprehensive testing, benchmarking, and validation ## Architecture The system consists of three primary components: ``` ┌──────────────────────────────────────────────────────────────────┐ │ C# to C++ Conversion System │ ├──────────────────────────────────────────────────────────────────┤ │ │ │ ┌────────────────────┐ ┌─────────────────────┐ │ │ │ C# Analyzer │ │ C++ Orchestrator │ │ │ │ Service │◄─────►│ (Pipeline Engine) │ │ │ │ (.NET 8 + Roslyn) │ gRPC │ (Python 3.11+) │ │ │ └────────────────────┘ └─────────────────────┘ │ │ │ │ │ │ │ │ ▼ │ │ ┌─────────────────────┐ │ │ │ C++ Runtime Shim │ │ │ │ (C++20 Library) │ │ │ └─────────────────────┘ │ │ │ └──────────────────────────────────────────────────────────────────┘ ``` ### Component Responsibilities 1. **[csharp-analyzer-service](./csharp-analyzer-service/README.md)**: - Roslyn-based semantic analysis - Type resolution and symbol extraction - Dependency graph construction - gRPC service interface 2. **[cpp-orchestrator](./cpp-orchestrator/README.md)**: - Conversion pipeline orchestration - Transformation rule engine - Template-based C++ code generation - Progress tracking and error handling 3. **[cpp-runtime-shim](./cpp-runtime-shim/README.md)**: - .NET-compatible type system - Collections (List, Dictionary, etc.) - String handling (UTF-16 compatible) - LINQ-like query operators - Async/await support (coroutines) ## Quick Start ### Prerequisites - **.NET 8 SDK** (for C# Analyzer Service) - **Python 3.11+** (for C++ Orchestrator) - **CMake 3.20+** (for C++ Runtime Shim) - **C++20-capable compiler**: GCC 11+, Clang 15+, or MSVC 2022+ ### Installation ```bash # Clone the repository git clone https://github.com/your-org/csharp-to-cpp.git cd csharp-to-cpp # Build C# Analyzer Service cd csharp-analyzer-service dotnet build -c Release # Install C++ Orchestrator cd ../cpp-orchestrator pip install -e ".[dev]" # Build C++ Runtime Shim cd ../cpp-runtime-shim cmake -S . -B build -DCMAKE_BUILD_TYPE=Release cmake --build build ``` ### Basic Usage ```bash # Convert a C# project to C++ cpp-orchestrator convert \ --input /path/to/csharp/project \ --output /path/to/cpp/output \ --analyzer-service localhost:50051 ``` See the [User Guide](./docs/user-guide.md) (to be created) for detailed usage instructions. ## Repository Structure ``` csharp-to-cpp/ ├── csharp-analyzer-service/ # .NET 8 Roslyn analyzer gRPC service ├── cpp-orchestrator/ # Python orchestration engine ├── cpp-runtime-shim/ # C++ runtime compatibility layer ├── shared-config/ # Shared configuration and standards ├── docs/ # Documentation and ADRs │ └── adr/ # Architecture Decision Records ├── samples/ # Sample C# codebases for testing ├── benchmarks/ # Performance benchmarking suite └── test_cases_repos/ # Test repositories (existing) ``` See [ADR-001: Repository Structure](./docs/adr/001-repository-structure.md) for the rationale behind this organization. ## Development ### Project Status **Current Phase**: Phase 0 - Foundation (Directory Structure Setup) **Roadmap**: - **Phase 0**: ✅ Directory structure and foundational configuration - **Phase 1**: Core implementation of analyzer, orchestrator, and runtime (In Progress) - **Phase 2**: Basic conversion capabilities (planned) - **Phase 3**: Advanced features (LINQ, async/await) (planned) - **Phase 4**: Production hardening and optimization (planned) - **Phase 5**: Framework support and ecosystem integration (planned) See [Detailed Implementation Plan](./detailed_implementation_plan.md) for the complete roadmap. ### Building from Source Each component can be built independently: #### C# Analyzer Service ```bash cd csharp-analyzer-service dotnet restore dotnet build -c Release dotnet test ``` #### C++ Orchestrator ```bash cd cpp-orchestrator pip install -e ".[dev]" pytest black . && ruff check . && mypy src/ ``` #### C++ Runtime Shim ```bash cd cpp-runtime-shim cmake -S . -B build -DBUILD_TESTING=ON cmake --build build ctest --test-dir build ``` ### Running Tests ```bash # Run all tests ./scripts/test-all.sh # Run component-specific tests ./scripts/test-component.sh csharp-analyzer-service ./scripts/test-component.sh cpp-orchestrator ./scripts/test-component.sh cpp-runtime-shim ``` ### Code Style Each component follows language-specific style guidelines: - **C#**: .editorconfig in `csharp-analyzer-service/` - **Python**: Black formatter + Ruff linter (configured in `pyproject.toml`) - **C++**: clang-format (configured in `.clang-format`) See [Shared Configuration](./shared-config/README.md) for cross-cutting standards. ## Documentation - **[Architecture Decision Records (ADRs)](./docs/adr/)**: Design decisions and rationale - **[Component READMEs](./csharp-analyzer-service/README.md)**: Detailed component documentation - **[Samples](./samples/README.md)**: Example conversions and test cases - **[Benchmarks](./benchmarks/README.md)**: Performance testing and validation Additional documentation (to be created in Phase 1): - User Guide - API Reference - Conversion Guide - Troubleshooting - Contributing Guidelines ## Testing Strategy ### Test Levels 1. **Unit Tests**: Component-internal functionality 2. **Integration Tests**: Cross-component interaction 3. **End-to-End Tests**: Full conversion pipeline validation 4. **Regression Tests**: Prevent breaking changes to working conversions 5. **Performance Tests**: Benchmark runtime and conversion performance ### Test Infrastructure - **C# Tests**: xUnit with FluentAssertions - **Python Tests**: pytest with pytest-cov - **C++ Tests**: Google Test or Catch2 - **Integration Tests**: Docker Compose orchestration ## Continuous Integration GitHub Actions workflows for each component: - **On PR**: Linting, unit tests, integration tests - **On Push to main**: Full test suite + benchmarks - **Nightly**: Extended tests, performance benchmarks, sample conversions - **Weekly**: Large-scale integration tests ## Contributing We welcome contributions! Please: 1. Read the [Contributing Guide](./CONTRIBUTING.md) (to be created) 2. Check existing issues or create a new one 3. Fork the repository and create a feature branch 4. Follow code style guidelines 5. Write tests for new functionality 6. Submit a pull request ### Development Workflow 1. **Choose a component**: Pick the component you want to work on 2. **Set up environment**: Follow component-specific setup instructions 3. **Make changes**: Implement your feature or fix 4. **Run tests**: Ensure all tests pass 5. **Submit PR**: Create a pull request with clear description ## Performance Performance is a key goal of this project: ### Conversion Performance - Small codebases (< 1K LOC): < 5 seconds - Medium codebases (1-10K LOC): < 30 seconds - Large codebases (> 10K LOC): < 5 minutes ### Runtime Performance - Collections: Within 90-110% of C# performance - Algorithms: 100-150% of C# (C++ should be faster) - Memory: 50-80% of C# allocations (more deterministic) See [Benchmarks](./benchmarks/README.md) for detailed performance data. ## License [MIT License](./LICENSE) (or specify your license) ## Support and Contact - **Issues**: [GitHub Issues](https://github.com/your-org/csharp-to-cpp/issues) - **Discussions**: [GitHub Discussions](https://github.com/your-org/csharp-to-cpp/discussions) - **Email**: support@your-org.com ## Acknowledgments This project builds upon: - Microsoft Roslyn compiler platform - The C++ Standards Committee for modern C++ features - Open-source C# and C++ communities ## Frequently Asked Questions ### Why convert C# to C++? Common reasons include: - Performance requirements (game engines, HPC, embedded systems) - Platform constraints (no .NET runtime available) - Integration with existing C++ codebases - Reduced deployment size and dependencies - Real-time or deterministic performance needs ### What C# features are supported? See [Feature Support Matrix](./docs/feature-support.md) (to be created) for a complete list. **Well Supported**: - Classes, structs, enums - Inheritance and interfaces - Generics (via templates) - Properties and indexers - LINQ (via C++20 ranges) - Async/await (via coroutines) **Limited Support**: - Reflection (compile-time only) - Dynamic types (not supported) - Framework-specific APIs (requires shimming) ### How accurate is the conversion? The system aims for: - **Semantic Equivalence**: Same behavior as original C# - **Idiomatic C++**: Generated code follows C++ best practices - **Performance**: Equal or better performance than C# Validation through extensive testing ensures behavioral parity. ### Can I customize the conversion? Yes! The transformation rules engine is fully customizable: - Custom type mappings - Pattern-specific transformations - Template modifications - Runtime shim extensions See [Customization Guide](./docs/customization.md) (to be created). ## Project Status and Versioning **Current Version**: 0.1.0-alpha (Phase 0 complete) **Stability**: Early Development - APIs subject to change - Not yet recommended for production use - Active development and iteration **Release Schedule**: - **v0.1.0**: Phase 0-1 complete (foundation + core) - **v0.2.0**: Phase 2 complete (basic conversions) - **v0.3.0**: Phase 3 complete (advanced features) - **v1.0.0**: Production ready (Phase 4 complete) --- **Built with modern tooling for reliable, performant C# to C++ conversion.**