# stryker-mutator/stryker-net architecture

> Architecture diagram of the GitHub repository stryker-mutator/stryker-net, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/stryker-mutator/stryker-net
- Repository: https://github.com/stryker-mutator/stryker-net

## Overview

##### Project type and purpose
- This is a CLI-based mutation testing tool (stryker.NET) for .NET Core/Framework projects.
- Key responsibilities: read user config, analyze & mutate source code, run tests, collect coverage, apply filters, and generate mutation reports (HTML/JSON/CLI).

##### File structure
- Top-level modules under `src`:
– Stryker.CLI: the entry point and command-line interface
– Stryker.Core: the mutation testing engine
– Stryker.Abstractions: interfaces & shared types (dependency inversion)
– Stryker.TestRunner.VsTest & Stryker.TestRunner: adapters for running tests via VSTest
– Stryker.DataCollector: coverage collection logic
– Stryker.Options: configuration definitions & validation
– Stryker.RegexMutators: regex-specific mutators plugin
– Stryker.Utilities: shared helpers (MSBuild, Roslyn, logging, file utils)
- Each module has its own unit tests under corresponding `*.UnitTest` folders.
- Build logic and packaging via Directory.Build.* props & targets.
- Documentation and example projects under docs/ and ExampleProjects/.

##### Additional insights from README
- dotnet global tool (`dotnet-stryker`) – invoked from shell
- Target runtimes: .NET Core, .NET Framework, .NET Standard
- Outputs interactive HTML report, CLI summary, JSON for dashboard
- Supports baseline comparison (Azure/Dashboard/Disk)

##### Main components & interactions
1. CLI Layer (Stryker.CLI)
2. Configuration (Stryker.Options + file readers)
3. Core Engine (Stryker.Core)
– Initialization
– Compilation (Roslyn via Utilities)
– Mutation Generation (Mutators, InjectedHelpers, Instrumentation)
– Mutation Filters & Orchestration
– Mutation Test Execution
4. Test Runner Adapter (Stryker.TestRunner.VsTest & Stryker.TestRunner)
5. Coverage Collector (Stryker.DataCollector)
6. Reporters (HTML, JSON, Console)
7. Abstractions (interfaces for injection & extension)
8. External Services
– MSBuild / NuGet Restore
– Visual Studio Test Platform (VSTest)
– Dashboard API (optional baseline)
- CLI → Configuration builder → Core Engine start
- Core Engine → MSBuild/NuGet (via Utilities) → compile original code
- Core Engine → Mutation Generator → produce mutated assemblies
- For each mutant:
– Core Engine → Test Runner → execute tests (via VsTestAdapter)
– Test Runner → Coverage Collector (for coverage mode)
- Core Engine → Filters → determine killed/survived mutants
- Core Engine → Reporters → HTML/JSON/Console output
- Optionally: Core Engine → Dashboard client (via Abstractions)
c. Architectural patterns & principles
- Layered architecture: CLI → Core → Test Runner → Reporters
- Dependency inversion: all implementations depend on `Stryker.Abstractions` interfaces
- Plugin-like mutator design: new mutators (CSharp, Regex) extend base Mutator classes
- Factory & Strategy for BaselineProviders, DiffProviders, MutantFilters
d. Relevant technologies
- .NET Core/.NET Framework CLI tool
- Roslyn for compilation & syntax tree mutation
- MSBuild APIs for project analysis
- VSTest platform for test execution
- SSE for real-time HTML reporting
- HTTP client for Dashboard upload

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "CLI Layer"
        CLI["Stryker.CLI"]:::config
    end

    subgraph "Configuration"
        Config["Configuration (Stryker.Options)"]:::config
    end

    subgraph "Core Engine"
        subgraph "Initialisation & Orchestration"
            Init["InitialisationProcess"]:::core
            Build["InitialBuildProcess"]:::core
            Orch["ProjectOrchestrator"]:::core
            MutatorOrch["ProjectMutator"]:::core
        end
        subgraph "Compilation"
            Comp["CsharpCompilingProcess"]:::core
            Rollback["CSharpRollbackProcess"]:::core
            MSBuildHelper["MsBuildHelper"]:::infra
            RoslynHelper["RoslynHelper"]:::infra
        end
        subgraph "Mutation Generation"
            Mutators["Mutators"]:::core
            NodeOrch["CsharpNodeOrchestrators"]:::core
            Instrumentation["Instrumentation Engines"]:::core
            Injected["InjectedHelpers"]:::core
        end
        subgraph "Filtering & Orchestration"
            Filters["MutantFilters"]:::core
        end
        subgraph "Mutation Test Execution"
            MutationExec["MutationTestExecutor"]:::core
            MutationProc["MutationTestProcess"]:::core
            CsharpMutProc["CsharpMutationProcess"]:::core
        end
        Runner["StrykerRunner"]:::core
        Result["StrykerRunResult"]:::core
    end

    subgraph "Test Runner Adapters"
        VsTest["VsTest Runner"]:::adapter
        GenericTR["Generic Test Runner"]:::adapter
    end

    subgraph "Coverage Collector"
        CoverageCollector["CoverageCollector"]:::adapter
        CoverageAnalyser["CoverageAnalyser"]:::core
    end

    subgraph "Reporters"
        ConsoleReporter["Console & Progress Reporters"]:::report
        HtmlReporter["HTML Reporter"]:::report
        JsonReporter["JSON Reporter"]:::report
        DashboardReporter["Dashboard & Baseline Reporters"]:::report
        ReportsStorage["Mutation Reports"]:::data
    end

    Abstractions["Stryker.Abstractions"]:::abstraction
    Utilities["Utilities & Helpers"]:::infra
    RegexPlugin["Regex Mutators Plugin"]:::infra

    ExternalMSBuild["MSBuild / NuGet"]:::external
    DashboardAPI["Dashboard API"]:::external

    CLI -->|"reads config"| Config
    Config -->|"builds settings"| Init
    Init --> CompileFlow
    CompileFlow((( ))) --> Comp
    Comp --> Rollback
    Comp --> MSBuildHelper
    Comp --> RoslynHelper
    MSBuildHelper --> ExternalMSBuild
    RoslynHelper --> Utilities
    Comp --> Mutators
    Mutators --> NodeOrch
    NodeOrch --> Instrumentation
    Instrumentation --> Injected
    Injected --> MutationExec
    MutationExec --> VsTest
    VsTest --> VSCTestPlatform
    MutationExec --> GenericTR
    VsTest --> CoverageCollector
    GenericTR --> CoverageCollector
    CoverageCollector --> CoverageAnalyser
    CoverageAnalyser --> Filters
    Filters --> Runner
    Runner --> Result
    Result --> ConsoleReporter
    Result --> HtmlReporter
    Result --> JsonReporter
    Result --> DashboardReporter
    HtmlReporter --> ReportsStorage
    JsonReporter --> ReportsStorage
    ConsoleReporter --> ReportsStorage
    DashboardReporter --> DashboardAPI
    Mutators --> RegexPlugin
    Init --> Utilities
    Filters --> Abstractions
    VsTest --> Abstractions
    ConsoleReporter --> Abstractions
    HtmlReporter --> Abstractions
    JsonReporter --> Abstractions
    DashboardReporter --> Abstractions

    click CLI "https://github.com/stryker-mutator/stryker-net/blob/master/src/Stryker.CLI/Stryker.CLI"
    click Config "https://github.com/stryker-mutator/stryker-net/tree/master/src/Stryker.Options/Options"
    click Init "https://github.com/stryker-mutator/stryker-net/blob/master/src/Stryker.Core/Stryker.Core/Initialisation/InitialisationProcess.cs"
    click Build "https://github.com/stryker-mutator/stryker-net/blob/master/src/Stryker.Core/Stryker.Core/Initialisation/InitialBuildProcess.cs"
    click Orch "https://github.com/stryker-mutator/stryker-net/blob/master/src/Stryker.Core/Stryker.Core/Initialisation/ProjectOrchestrator.cs"
    click MutatorOrch "https://github.com/stryker-mutator/stryker-net/blob/master/src/Stryker.Core/Stryker.Core/Initialisation/ProjectMutator.cs"
    click Comp "https://github.com/stryker-mutator/stryker-net/blob/master/src/Stryker.Core/Stryker.Core/Compiling/CsharpCompilingProcess.cs"
    click Rollback "https://github.com/stryker-mutator/stryker-net/blob/master/src/Stryker.Core/Stryker.Core/Compiling/CSharpRollbackProcess.cs"
    click MSBuildHelper "https://github.com/stryker-mutator/stryker-net/blob/master/src/Stryker.Core/Stryker.Core/Helpers/MsBuildHelper.cs"
    click RoslynHelper "https://github.com/stryker-mutator/stryker-net/blob/master/src/Stryker.Core/Stryker.Core/Helpers/RoslynHelper.cs"
    click Mutators "https://github.com/stryker-mutator/stryker-net/tree/master/src/Stryker.Core/Stryker.Core/Mutators"
    click NodeOrch "https://github.com/stryker-mutator/stryker-net/tree/master/src/Stryker.Core/Stryker.Core/Mutants/CsharpNodeOrchestrators"
    click Instrumentation "https://github.com/stryker-mutator/stryker-net/tree/master/src/Stryker.Core/Stryker.Core/Instrumentation"
    click Injected "https://github.com/stryker-mutator/stryker-net/tree/master/src/Stryker.Core/Stryker.Core/InjectedHelpers"
    click Filters "https://github.com/stryker-mutator/stryker-net/tree/master/src/Stryker.Core/Stryker.Core/MutantFilters"
    click MutationExec "https://github.com/stryker-mutator/stryker-net/blob/master/src/Stryker.Core/Stryker.Core/MutationTest/MutationTestExecutor.cs"
    click MutationProc "https://github.com/stryker-mutator/stryker-net/blob/master/src/Stryker.Core/Stryker.Core/MutationTest/MutationTestProcess.cs"
    click CsharpMutProc "https://github.com/stryker-mutator/stryker-net/blob/master/src/Stryker.Core/Stryker.Core/MutationTest/CsharpMutationProcess.cs"
    click Runner "https://github.com/stryker-mutator/stryker-net/blob/master/src/Stryker.Core/Stryker.Core/StrykerRunner.cs"
    click Result "https://github.com/stryker-mutator/stryker-net/blob/master/src/Stryker.Core/Stryker.Core/StrykerRunResult.cs"
    click VsTest "https://github.com/stryker-mutator/stryker-net/blob/master/src/Stryker.TestRunner.VsTest"
    click GenericTR "https://github.com/stryker-mutator/stryker-net/blob/master/src/Stryker.TestRunner"
    click CoverageCollector "https://github.com/stryker-mutator/stryker-net/blob/master/src/Stryker.DataCollector/Stryker.DataCollector"
    click CoverageAnalyser "https://github.com/stryker-mutator/stryker-net/tree/master/src/Stryker.Core/Stryker.Core/CoverageAnalysis"
    click ConsoleReporter "https://github.com/stryker-mutator/stryker-net/tree/master/src/Stryker.Core/Stryker.Core/Reporters"
    click HtmlReporter "https://github.com/stryker-mutator/stryker-net/tree/master/src/Stryker.Core/Stryker.Core/Reporters/Html"
    click JsonReporter "https://github.com/stryker-mutator/stryker-net/tree/master/src/Stryker.Core/Stryker.Core/Reporters/Json"
    click DashboardReporter "https://github.com/stryker-mutator/stryker-net/tree/master/src/Stryker.Core/Stryker.Core/Reporters"
    click Abstractions "https://github.com/stryker-mutator/stryker-net/blob/master/src/Stryker.Abstractions"
    click Utilities "https://github.com/stryker-mutator/stryker-net/blob/master/src/Stryker.Utilities"
    click RegexPlugin "https://github.com/stryker-mutator/stryker-net/blob/master/src/Stryker.RegexMutators/Stryker.RegexMutators"
    click ExternalMSBuild "https://github.com/stryker-mutator/stryker-net/blob/master/src/Stryker.Utilities/Buildalyzer/Buildalyzer.cs"
    click DashboardAPI "https://github.com/stryker-mutator/stryker-net/blob/master/src/Stryker.Core/Stryker.Core/Clients/DashboardClient.cs"

    classDef core fill:#add8e6,stroke:#0000ff,color:#000
    classDef adapter fill:#90ee90,stroke:#008000,color:#000
    classDef config fill:#ffffe0,stroke:#cccc00,color:#000
    classDef abstraction fill:#ffffe0,stroke:#cccc00,color:#000
    classDef infra fill:#90ee90,stroke:#008000,color:#000
    classDef report fill:#ffdead,stroke:#ffa500,color:#000
    classDef data fill:#ffe4e1,stroke:#ff0000,color:#000
    classDef external fill:#ffdab9,stroke:#ff4500,color:#000
```
