# lukamicoder/astyle-extension architecture

> Architecture diagram of the GitHub repository lukamicoder/astyle-extension, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lukamicoder/astyle-extension
- Repository: https://github.com/lukamicoder/astyle-extension

## Overview

##### Project type and purpose
- This is a Visual Studio (and Atmel Studio/AVR Studio) extension written in C# that integrates the Artistic Style (AStyle) code-formatting engine.
- Its purpose is to provide menu commands, settings pages, and automatic formatting on save for C/C++ and C# documents inside the IDE.

##### File structure
- Top-level:
- .gitignore, README.md
- astyle-extension/astyle-extension2017.sln – the Visual Studio solution file
- Under astyle-extension/AStyleExtension:
- Source code files (.cs, .Designer.cs, .resx) implementing the extension logic, UI dialogs, and options pages
- DocumentEventListener.cs – hooks into document events (format-on-save, on-command)
- AStyleInterface.cs – C# wrapper around the native AStyle DLL
- AStyleSettings.cs and related forms – store and display formatting options
- VSCT and manifest files (AStyleExtension.vsct, source.extension.vsixmanifest) – define commands and package metadata
- AsyncPackageRegistrationAttribute.cs, ProvideAutoLoadAttribute.cs, Guids.cs, PkgCmdID.cs – boilerplate for registering the VS Package
- Properties and Resources – assembly info, license text, localized strings
- packages.config – NuGet package references (if any)
- app.config – configuration for the extension (e.g., binding redirects)

##### README for additional insights
- Confirms supported IDE versions and the underlying AStyle engine version.

##### Details
- Responsibility as a separate component.
- Both user-initiated formatting and automatic format-on-save.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Host
    VSHost["Visual Studio Host"]:::host

    %% VSIX Package Boundary
    subgraph "VSIX Package" 
        direction TB
        Solution["Extension Solution (.sln)"]:::managed
        CSProj["VSIX Project (.csproj)"]:::managed
        VSIXManifest["source.extension.vsixmanifest"]:::managed
        VSIXManifest2010["VS2010/source.extension.vsixmanifest"]:::managed
        VSCT["AStyleExtension.vsct"]:::managed

        AStyleExtensionPackage["AStyleExtensionPackage"]:::managed
        AsyncReg["AsyncPackageRegistrationAttribute"]:::managed
        AutoLoad["ProvideAutoLoadAttribute"]:::managed
        Guids["Guids & PkgCmdID"]:::managed

        CommandService["Command Service"]:::managed
        DocumentListener["DocumentEventListener"]:::managed
        AStyleSettingsComp["AStyleSettings"]:::managed

        subgraph "Settings UI"
            direction TB
            GeneralPage["AStyleGeneralOptionsPage"]:::managed
            GeneralControl["AStyleGeneralOptionsControl"]:::managed
            SettingsForm["AStyleSettingsForm"]:::managed
        end

        AStyleInterface["AStyleInterface"]:::managed
        ErrorArgs["AStyleErrorArgs"]:::managed
        EditForm["AStyleEditForm"]:::managed

        NativeDLL["Native AStyle DLL"]:::native
    end

    %% Interactions
    VSHost -->|"loads via ProvideAutoLoad"| AStyleExtensionPackage
    AStyleExtensionPackage -->|"registers commands & options"| CommandService
    CommandService -->|"user invokes Format Document"| DocumentListener
    DocumentListener -->|"reads buffer & settings"| AStyleSettingsComp
    DocumentListener -->|"calls"| AStyleInterface
    AStyleInterface -->|"P/Invoke"| NativeDLL
    NativeDLL -->|"formatted text"| AStyleInterface
    AStyleInterface -->|"returns result"| DocumentListener
    DocumentListener -->|"updates editor buffer"| VSHost

    %% Settings flow
    GeneralPage --> AStyleSettingsComp
    GeneralControl --> AStyleSettingsComp
    SettingsForm --> AStyleSettingsComp

    %% Click Events
    click Solution "https://github.com/lukamicoder/astyle-extension/blob/master/astyle-extension/astyle-extension2017.sln"
    click CSProj "https://github.com/lukamicoder/astyle-extension/blob/master/astyle-extension/AStyleExtension/AStyleExtension2017.csproj"
    click VSIXManifest "https://github.com/lukamicoder/astyle-extension/blob/master/astyle-extension/AStyleExtension/source.extension.vsixmanifest"
    click VSIXManifest2010 "https://github.com/lukamicoder/astyle-extension/blob/master/astyle-extension/AStyleExtension/VS2010/source.extension.vsixmanifest"
    click VSCT "https://github.com/lukamicoder/astyle-extension/blob/master/astyle-extension/AStyleExtension/AStyleExtension.vsct"
    click AsyncReg "https://github.com/lukamicoder/astyle-extension/blob/master/astyle-extension/AStyleExtension/AsyncPackageRegistrationAttribute.cs"
    click AutoLoad "https://github.com/lukamicoder/astyle-extension/blob/master/astyle-extension/AStyleExtension/ProvideAutoLoadAttribute.cs"
    click Guids "https://github.com/lukamicoder/astyle-extension/blob/master/astyle-extension/AStyleExtension/Guids.cs"
    click Guids "https://github.com/lukamicoder/astyle-extension/blob/master/astyle-extension/AStyleExtension/PkgCmdID.cs"
    click AStyleExtensionPackage "https://github.com/lukamicoder/astyle-extension/blob/master/astyle-extension/AStyleExtension/AStyleExtensionPackage.cs"
    click DocumentListener "https://github.com/lukamicoder/astyle-extension/blob/master/astyle-extension/AStyleExtension/DocumentEventListener.cs"
    click AStyleInterface "https://github.com/lukamicoder/astyle-extension/blob/master/astyle-extension/AStyleExtension/AStyleInterface.cs"
    click AStyleSettingsComp "https://github.com/lukamicoder/astyle-extension/blob/master/astyle-extension/AStyleExtension/AStyleSettings.cs"
    click GeneralPage "https://github.com/lukamicoder/astyle-extension/blob/master/astyle-extension/AStyleExtension/AStyleGeneralOptionsPage.cs"
    click GeneralControl "https://github.com/lukamicoder/astyle-extension/blob/master/astyle-extension/AStyleExtension/AStyleGeneralOptionsControl.cs"
    click SettingsForm "https://github.com/lukamicoder/astyle-extension/blob/master/astyle-extension/AStyleExtension/AStyleSettingsForm.cs"
    click EditForm "https://github.com/lukamicoder/astyle-extension/blob/master/astyle-extension/AStyleExtension/AStyleEditForm.cs"
    click ErrorArgs "https://github.com/lukamicoder/astyle-extension/blob/master/astyle-extension/AStyleExtension/AStyleErrorArgs.cs"
    click NativeDLL "https://github.com/lukamicoder/astyle-extension/tree/master/astyle-extension/AStyleExtension/AStyle"

    %% Styles
    classDef host fill:#ccc,stroke:#333,stroke-width:1px
    classDef managed fill:#b3d9ff,stroke:#333,stroke-width:1px
    classDef native fill:#b3ffb3,stroke:#333,stroke-width:1px
```
