# dmako/commonnetextensions architecture

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

- Interactive diagram: https://gitdiagram.com/dmako/commonnetextensions
- Repository: https://github.com/dmako/commonnetextensions

## Overview

- CommonNet.Extensions – Provides various extension methods for system types (collections, I/O, networking, reflection, etc.).
- CommonNet.Logging – Offers logging extensions built on top of Microsoft and third‐party libraries like Serilog.
- CommonNet.DependencyInjection – Contains extension methods to help register services into the dependency injection container (wrapping Microsoft.Extensions.DependencyInjection).
- CommonNet.Json – Adds JSON converters for common types (such as URIs, IP addresses, etc.).

There is also a CommonNet.Extensions.Tests directory, which shows that unit tests are integral in validating the functionality of these libraries.

##### And outline the key components
a. Library Modules:
– A module for CommonNet.Logging: Highlight that this library wraps logging functionalities and contains both the base logging extensions and specific implementations (Microsoft.Extensions.Logging wrappers and Serilog enrichers).
– A module for CommonNet.DependencyInjection: This module adds extension methods for the DI container registration. It contains multiple files to add infrastructure-methods for scoped, transient, and singleton lifetimes.
– A module for CommonNet.Json: Emphasize its JSON converter components for common .NET data types.
b. Testing Suite:

##### Architectural patterns
– Modular design: Each library is a self-contained module that provides specialized functionality.
– Separation of concerns: Each library focuses on a specific domain (extensions, logging, DI, JSON).
– Reusability and extensibility: The idea is to have reusable components that can be integrated into various projects.
– Emphasis on unit testing: A dedicated tests module confirms that the design follows best practices for maintainability and reliability.

##### Technologies and frameworks
– .NET (obviously as the platform).
– Microsoft.Extensions.DependencyInjection for DI.
– Serilog for logging components.
– Standard .NET libraries extended via extension methods.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "CommonNetExtensions.sln"
        %% Libraries Subgraph
        subgraph "Libraries"
            A["CommonNet.Extensions"]:::library
            B["CommonNet.Logging"]:::library
            C["CommonNet.DependencyInjection"]:::library
            D["CommonNet.Json"]:::library
        end
        %% Testing Subgraph
        subgraph "Testing"
            E["CommonNet.Extensions.Tests"]:::test
        end
    end

    %% Sub-components for DependencyInjection
    C1["ServiceCollectionExtensions.AddScoped"]:::library
    C --> C1

    %% Sub-components for CommonNet.Json converters
    D1["AbsoluteUriJsonConverter"]:::library
    D2["IPAddressJsonConverter"]:::library
    D3["IPEndPointJsonConverter"]:::library
    D --> D1
    D --> D2
    D --> D3

    %% External Dependencies
    ext1["Microsoft.Extensions.Logging"]:::external
    ext2["Serilog"]:::external
    ext3["Microsoft.Extensions.DependencyInjection"]:::external

    %% Relationships: Libraries and Externals
    B -.->|"wraps"| ext1
    B -.->|"integrates"| ext2
    C -.->|"uses"| ext3

    %% Relationships: Testing interacts with Libraries
    E -->|"tests"| A
    E -->|"tests"| B
    E -->|"tests"| C
    E -->|"tests"| D

    %% Styles
    classDef library fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef test fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:2px,stroke-dasharray: 5,5;

    %% Click Events
    click A "https://github.com/dmako/commonnetextensions/blob/devel/CommonNet.Extensions"
    click B "https://github.com/dmako/commonnetextensions/blob/devel/CommonNet.Logging"
    click C "https://github.com/dmako/commonnetextensions/blob/devel/CommonNet.DependencyInjection"
    click D "https://github.com/dmako/commonnetextensions/blob/devel/CommonNet.Json"
    click E "https://github.com/dmako/commonnetextensions/blob/devel/CommonNet.Extensions.Tests"
    click C1 "https://github.com/dmako/commonnetextensions/blob/devel/CommonNet.DependencyInjection/Microsoft.Extensions.DependencyInjection/ServiceCollectionExtensions.AddScoped.cs"
    click D1 "https://github.com/dmako/commonnetextensions/blob/devel/CommonNet.Json/AbsoluteUriJsonConverter.cs"
    click D2 "https://github.com/dmako/commonnetextensions/blob/devel/CommonNet.Json/IPAddressJsonConverter.cs"
    click D3 "https://github.com/dmako/commonnetextensions/blob/devel/CommonNet.Json/IPEndPointJsonConverter.cs"
```
