DotNetDupe 3.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package DotNetDupe --version 3.0.2
                    
NuGet\Install-Package DotNetDupe -Version 3.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DotNetDupe" Version="3.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DotNetDupe" Version="3.0.2" />
                    
Directory.Packages.props
<PackageReference Include="DotNetDupe" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DotNetDupe --version 3.0.2
                    
#r "nuget: DotNetDupe, 3.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DotNetDupe@3.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DotNetDupe&version=3.0.2
                    
Install as a Cake Addin
#tool nuget:?package=DotNetDupe&version=3.0.2
                    
Install as a Cake Tool

DotNetDupe ๐Ÿš€

Build Status Latest Release Language Platforms Code Coverage License

Ever admired the elegance and developer-friendliness of .NET APIs? ๐Ÿค” While the C++ Standard Template Library (STL) is powerful, its learning curve can be steep. This project, DotNetDupe, bridges that gap! ๐ŸŒ‰

Inspired by the clear and concise API design of C# .NET, DotNetDupe is a C++ library that brings a familiar, streamlined development experience to your C++ projects. โœจ

Major Update (Latest Version): DotNetDupe is now fully cross-platform! ๐ŸŒ Key highlights in this release include:

  • ๐ŸŒ Mini WebAppServer: Built-in web application server capabilities.
  • ๐Ÿ“Š System Metrics Collector: Comprehensive hardware and process resource monitoring.
  • ๐Ÿ–ฅ๏ธ Active Session Enumerator: Enumerate active user and system sessions.
  • ๐Ÿ‘ฅ System User Enumeration: Enumerate local system users.
  • ๐Ÿ”’ Named Synchronization: Enhanced sync primitives with cross-process named support (Mutex, EventWaitHandle, etc.).

We're starting with a foundational set of classes in the System and IO namespaces, offering a glimpse into the library's potential. Your contributions are highly welcome to expand its functionality! ๐Ÿค

A fun fact: While I personally crafted core components like Char, String, and Path (along with their tests), a significant portion of the remaining code was generated with the help of Gemini Code Assist. ๐Ÿค– This project serves as a unique playground for exploring how generative AI can accelerate development from scratch. ๐Ÿš€

DotNetDupe aims to simplify C++ development by providing C#-like interfaces for common tasks, making your code more concise, intuitive, and a joy to write. ๐Ÿ’–

Table of Contents ๐Ÿ“š

Project Overview ๐Ÿ’ก

The core objective of DotNetDupe is to bridge the gap between the power and performance of C++ and the ease of use and productivity offered by C# APIs. By providing C#-like interfaces for common programming tasks, DotNetDupe aims to:

  • Simplify C++ Development: Reduce the boilerplate and complexity often associated with STL, making C++ more approachable for developers accustomed to higher-level languages.
  • Enhance Readability: Promote cleaner and more readable code by adopting well-known C# API patterns.
  • Boost Productivity: Accelerate development cycles by offering intuitive and efficient tools for common operations.

Features โœจ

  • C#-like API Design: Intuitive and familiar interfaces for common programming constructs.
  • Exception Handling: Robust exception classes mimicking .NET's exception hierarchy.
  • String Manipulation: Powerful String class with comprehensive methods for text processing.
  • Path Utilities: Convenient functions for file system path operations.
  • Time and Time Zone Support: Core classes like DateTimeOffset, TimeSpan, TimeZone, and TimeZoneInfo for accurate time management.
  • Type System Enhancements: (Add more specific features as they are implemented, e.g., Object base class, IComparable, IClonable etc.)

Getting Started ๐Ÿš€

Prerequisites ๐Ÿ“‹

  • C++17 compatible compiler (e.g., MSVC, GCC, Clang)
  • CMake (for building, if applicable)
  • (Any other dependencies, e.g., Google Test for running tests)

Installation โฌ‡๏ธ

  1. Clone the repository:

    git clone https://github.com/sudheeshps/DotNetDupe.git
    cd DotNetDupe
    
  2. Build the solution and generate NuGet package: Run the automated build script from PowerShell:

    .\BuildAndPack.ps1
    

    This script will update the resource build timestamp, compile the x64 and x86 Release binaries, and output the NuGet package (DotNetDupe.3.0.0.nupkg) into the nuget_packages directory.

  3. Add local NuGet package source: To use the locally generated NuGet package, add the nuget_packages directory as a local NuGet source:

    nuget sources Add -Name "DotNetDupeLocal" -Source "D:\Personal\Projects\C++\DotNetDupe\nuget_packages"
    

    (Replace D:\Personal\Projects\C++\DotNetDupe with your actual solution root path.)

  4. Install the NuGet package in your project: In your C++ project, you can now install the DotNetDupe package using the NuGet Package Manager or the command line:

    nuget install DotNetDupe -OutputDirectory <YourProjectDirectory> -Source DotNetDupeLocal
    

    (Replace <YourProjectDirectory> with the path to your project where you want to install the package.)

  5. Integrate into your project: Once installed, ensure your project's .vcxproj file is configured to link against the DotNetDupe.lib and include its headers. The NuGet package's .targets file should handle most of this automatically.

Cross-Platform Support ๐ŸŒ

DotNetDupe is designed for high portability and officially supports Windows (via MSVC/MSBuild) and Linux (via GCC/Clang/CMake).

Building and Testing

Platform Build System Build Command Test Command
Windows MSBuild msbuild DotNetDupe.sln /p:Configuration=Release .\bin\x64\Release\DotNetDupeTests.exe
Linux / WSL CMake cmake -S . -B build && cmake --build build cd build && ctest

Integration via NuGet

DotNetDupe is distributed as a multi-platform NuGet package. It contains native binaries for:

  • win-x64 (DotNetDupe.dll)
  • linux-x64 (libDotNetDupe.so)

When you add the NuGet package to your project, the appropriate binary is automatically selected based on your target platform.

Note for Linux Users

On Linux, NuGet packages are typically managed via dotnet CLI or integrated into CMake projects using tools like vcpkg or by manually extracting the shared library (.so) and headers from the .nupkg (which is a ZIP file).

Example manual extraction:

unzip DotNetDupe.nupkg -d dotnetdupe_lib
# Use dotnetdupe_lib/include for headers
# Use dotnetdupe_lib/runtimes/linux-x64/native/libDotNetDupe.so for linking

WSL Setup Guide (Windows) ๐Ÿง

For Windows developers who want to build and test for Linux locally, we recommend using the Windows Subsystem for Linux (WSL).

1. Install WSL

If you haven't already, install Ubuntu via PowerShell:

wsl --install -d Ubuntu

2. Environment Provisioning

Inside your WSL terminal, install the C++ build chain and OpenSSL development headers:

sudo apt-get update
sudo apt-get install -y build-essential cmake libssl-dev pkg-config

3. Build & Test in WSL

Navigate to your project root (e.g., /mnt/d/Projects/DotNetDupe) and run:

# Create build directory
mkdir -p build-wsl && cd build-wsl

# Configure and Build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .

# Run Tests
ctest --output-on-failure

4. Running WSL Commands from PowerShell

You can also build and test for Linux directly from a Windows PowerShell terminal without manually entering the WSL shell:

# Create build directory
wsl -d Ubuntu -- bash -c "mkdir -p build-wsl"

# Configure
wsl -d Ubuntu -- bash -c "cd build-wsl && cmake .. -DCMAKE_BUILD_TYPE=Release"

# Build
wsl -d Ubuntu -- bash -c "cd build-wsl && cmake --build ."

# Run Tests (via CTest)
wsl -d Ubuntu -- bash -c "cd build-wsl && ctest"

# Run Tests (direct execution)
wsl -d Ubuntu -- bash -c "cd build-wsl && ./DotNetDupeTests"

# Run Demo Application
wsl -d Ubuntu -- bash -c "cd build-wsl && ./DotNetDupeDemo"

Developing Cross-Platform Applications ๐ŸŒ๐Ÿ’ป

DotNetDupe enables unified, cross-platform C++20 development across Windows (MSVC / MSBuild) and Linux (GCC/Clang via CMake or WSL).


1. Cross-Platform Project Architecture

When building a cross-platform application with DotNetDupe:

  • Use UTF-8 character encoding for cross-platform portability.
  • Rely on DotNetDupe::System::SmartPointer<T> for memory and resource cleanup.
  • Avoid platform-specific raw syscalls; use DotNetDupe abstractions like System::IO::Path, System::IO::File, System::Threading::Thread, and System::Net::Sockets::TcpClient.

2. Integrating via NuGet Package

You can package and consume DotNetDupe via NuGet across Windows and Linux (WSL / CMake) projects.

A. Generating the NuGet Package

Run the automated build script from PowerShell:

.\BuildAndPack.ps1

This updates the build timestamp, compiles both x64 and x86 Release binaries, and outputs DotNetDupe.3.0.0.nupkg inside the nuget_packages/ directory.

B. Consuming NuGet Package in Visual Studio (Windows)
  1. Add the local nuget_packages folder as a NuGet Package Source:
    nuget sources Add -Name "DotNetDupeLocal" -Source "D:\Personal\Projects\C++\DotNetDupe\nuget_packages"
    
  2. In Visual Studio, right-click your project โ†’ Manage NuGet Packages โ†’ Select DotNetDupeLocal โ†’ Install DotNetDupe.
C. Consuming NuGet Package on Linux / CMake (WSL)
  1. Extract DotNetDupe.3.0.0.nupkg (ZIP format) to a local directory:
    Expand-Archive -Path "nuget_packages\DotNetDupe.3.0.0.nupkg" -DestinationPath "DotNetDupe_NuGet" -Force
    
  2. Configure CMake pointing NUGET_PATH to the extracted package folder:
    cmake -S . -B build -DUSE_NUGET=ON -DNUGET_PATH="./DotNetDupe_NuGet"
    cmake --build build
    

3. Building a Web Application with Static Files & REST APIs

The WebAppServer class serves static website assets (index.html, CSS, JavaScript, images) alongside mapped REST endpoints.

Project Directory Layout
MyWebApp/
โ”œโ”€โ”€ wwwroot/
โ”‚   โ”œโ”€โ”€ index.html
โ”‚   โ””โ”€โ”€ site.css
โ””โ”€โ”€ main.cpp
Step 1: Create wwwroot/index.html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>DotNetDupe Web App</title>
    <link rel="stylesheet" href="site.css">
</head>
<body>
    <h1>DotNetDupe Web Application Server</h1>
    <p>Serving static assets and REST API endpoints simultaneously!</p>
    <button onclick="fetchWelcomeMessage()">Hit Welcome Endpoint</button>
    <p id="welcome-output"></p>

    <script>
        async function fetchWelcomeMessage() {
            const response = await fetch('/api/welcome?name=Developer');
            const data = await response.json();
            document.getElementById('welcome-output').innerText = data.message;
        }
    </script>
</body>
</html>
Step 2: C++ Application (main.cpp)

Here is a complete, compile-ready web application hosting index.html and responding with a welcome message on hitting /api/welcome:

#include "System/Console.h"
#include "System/SmartPointer.h"
#include "System/IO/File.h"
#include "System/IO/Path.h"
#include "WebAppCore/Builder/WebApplication.h"
#include "WebAppCore/Builder/WebApplicationBuilder.h"
#include "WebAppCore/Server/WebAppServer.h"

using namespace DotNetDupe::System;
using namespace DotNetDupe::WebAppCore::Builder;
using namespace DotNetDupe::WebAppCore::Server;
using namespace DotNetDupe::WebAppCore::Http;

int main() {
    Console::WriteLine("=============================================");
    Console::WriteLine(" Starting DotNetDupe Cross-Platform Web Server");
    Console::WriteLine("=============================================");

    String webRoot = "wwwroot";

    // 1. Initialize WebApplication Host
    auto builder = WebApplication::CreateBuilder();
    auto app = builder->Build();

    // 2. Map REST Endpoint (/api/welcome?name=...)
    app->MapGet("/api/welcome", [](SmartPointer<HttpContext> ctx) -> String {
        String name = "Guest";
        if (ctx->GetRequest()->GetQuery().ContainsKey("name")) {
            name = ctx->GetRequest()->GetQuery()["name"];
        }

        ctx->GetResponse()->SetContentType("application/json");
        return String("{\"status\":\"Success\",\"message\":\"Welcome to DotNetDupe Web Server, ") + name + "!\"}";
    });

    // 3. Initialize WebAppServer to serve website content (index.html & assets)
    WebAppServer server(app, webRoot);
    server.EnableStaticFiles("index.html");

    Console::WriteLine("Server running at: http://localhost:8080/index.html");
    Console::WriteLine("Welcome Endpoint at: http://localhost:8080/api/welcome?name=Developer");

    // 4. Start Server
    server.Run("http://localhost:8080/index.html");

    return 0;
}

Usage ๐Ÿ’ป

Here are some quick examples of how to use DotNetDupe:

#include <iostream>
#include "DotNetDupe/String.h"
#include "DotNetDupe/Path.h"
#include "DotNetDupe/BasicException.h"
#include "DotNetDupe/TimeZoneInfo.h"

int main() {
    // String Example
    DotNetDupe::System::String greeting = _T("Hello");
    DotNetDupe::System::String name = _T("World");
    DotNetDupe::System::String message = greeting + _T(", ") + name + _T("!");
    std::wcout << message << std::endl; // Output: Hello, World!

    // Path Example
    DotNetDupe::System::String fullPath = DotNetDupe::System::IO::Path::Combine({_T("C:\\"), _T("Users"), _T("document.txt")});
    std::wcout << L"Combined Path: " << fullPath << std::endl;

    // TimeZone Example
    DotNetDupe::System::TimeZoneInfo localTz = DotNetDupe::System::TimeZoneInfo::Local();
    std::wcout << L"Local TimeZone: " << localTz.GetDisplayName() << std::endl;

    // Exception Example
    try {
        throw DotNetDupe::System::BasicException<TCHAR>(_T("Something went wrong!"));
    } catch (const DotNetDupe::System::BasicException<TCHAR>& e) {
        std::wcout << L"Caught exception: " << e.What() << std::endl;
    }

    return 0;
}

Web API & Database Integration Guide ๐ŸŒ๐Ÿ—„๏ธ

This section provides comprehensive examples and recommended practices for hosting web services, consuming them, and using the database storage layer.

1. Hosting REST API Controllers

DotNetDupe provides an ASP.NET-like hosting model with dependency injection and controller-based routing in the WebAppCore namespaces.

Defining and Hosting a Controller
  1. Declare your data structure.
  2. Specialize the JsonConverter<T> for the structure to enable automatic serialization and deserialization.
  3. Inherit from ControllerBase and define your action methods.
  4. Bind routes using ControllerRouteBuilder and map them in the application host.
#include "WebAppCore/Builder/WebApplicationBuilder.h"
#include "WebAppCore/Builder/WebApplication.h"
#include "WebAppCore/Controllers/ControllerBase.h"
#include "System/Collections/Generic/List.h"

using namespace DotNetDupe::System;
using namespace DotNetDupe::WebAppCore::Builder;
using namespace DotNetDupe::WebAppCore::Controllers;

// 1. Declare the data model
struct ProductItem {
    String Name;
    int Price = 0;
};

// 2. Specialize JsonConverter for serialization/deserialization
namespace DotNetDupe {
    namespace System {
        namespace Text {
            namespace Json {
                template <>
                struct JsonConverter<ProductItem> {
                    static JsonElement Write(const ProductItem& value) {
                        JsonElement obj(JsonValueKind::Object);
                        obj.SetProperty("name", JsonElement(value.Name));
                        obj.SetProperty("price", JsonElement(static_cast<double>(value.Price)));
                        return obj;
                    }
                    static ProductItem Read(const JsonElement& element) {
                        ProductItem p;
                        JsonElement prop;
                        if (element.TryGetProperty("name", prop)) p.Name = prop.GetString();
                        if (element.TryGetProperty("price", prop)) p.Price = prop.GetInt32();
                        return p;
                    }
                };
            }
        }
    }
}

// 3. Define the controller
class ProductsController : public ControllerBase {
public:
    // GET /api/products
    Collections::Generic::List<ProductItem> GetProducts() {
        Collections::Generic::List<ProductItem> list;
        list.Add(ProductItem{"Espresso Machine", 299});
        list.Add(ProductItem{"Coffee Grinder", 89});
        return list;
    }

    // POST /api/products
    String CreateProduct(const ProductItem& product) {
        return Created(String("Added ") + product.Name);
    }
};

int main() {
    auto builder = WebApplication::CreateBuilder();

    // 4. Register and configure routes on the controller
    builder->AddController<ProductsController>("/api/products")
        .MapGet("", &ProductsController::GetProducts)
        .MapPost("", &ProductsController::CreateProduct);

    auto app = builder->Build();
    app->MapControllers(); // Applies the registered mappings

    app->Run("http://127.0.0.1:5000");
}

2. Consuming REST APIs

DotNetDupe makes client-side web requests simple. You can query endpoints using a low-level HTTP client or a strongly-typed REST resource client.

Option A: Low-level HTTP Client (HttpClient)

Best for general, raw request handling, sending custom headers, or performing authentication (like setting Bearer tokens).

#include "System/Net/Http/HttpClient.h"
#include "System/Console.h"

void GetRawData() {
    using namespace DotNetDupe::System::Net::Http;
    
    HttpClient client;
    
    // Add default headers (e.g. JWT Auth token)
    client.GetDefaultRequestHeaders().Add("Authorization", "Bearer your_token_here");
    
    auto response = client.Get("http://127.0.0.1:5000/api/products");
    if (response->GetStatusCode() == 200) {
        DotNetDupe::System::String json = response->GetContent()->ReadAsString();
        DotNetDupe::System::Console::WriteLine(json);
    }
}

Best for standard RESTful resources. It handles payload serialization/deserialization to your model structures automatically.

#include "System/Net/Http/RestClient.h"
#include "System/Console.h"

void SyncProducts() {
    using namespace DotNetDupe::System::Net::Http;
    
    // Point the RestClient to your resource endpoint
    RestClient<ProductItem> client("http://127.0.0.1:5000/api/products");
    
    // GET all resources automatically parsed into List<T>
    auto products = client.GetAll();
    
    // POST new resource automatically serialized to JSON
    ProductItem newProduct{"Milk Frother", 35};
    DotNetDupe::System::String reply = client.Post(newProduct);
}

3. Using the Database Layer

DotNetDupe emulates C# ADO.NET (SqlConnection, SqlCommand, SqlDataReader) for SQL execution.

  1. Routing and Engine Fallback via Connection String:
    • In-Memory Emulation (Default): Use Engine=InMemory; for unit testing or when you don't want server/file dependencies. This runs an in-memory SQL parsing engine.
    • Persistent SQLite: Use Engine=SQLite; Data Source=my_db.db; when you need actual SQLite file persistence. Note: Requires compilation with the DOTNETDUPE_USE_SQLITE flag defined.
  2. Always Parameterize Queries: Use AddWithValue parameters to protect queries against parsing issues and SQL syntax injections.
  3. Use RAII and Smart Pointers: Wrap database commands and readers in smart pointers to guarantee resource cleanup.
#include "System/Data/SqlClient/SqlConnection.h"
#include "System/Data/SqlClient/SqlCommand.h"
#include "System/Console.h"

void AccessDatabase() {
    using namespace DotNetDupe::System;
    using namespace DotNetDupe::System::Data::SqlClient;

    try {
        // Connect. Uses default In-Memory emulation engine if SQLite is not compiled.
        SqlConnection conn("Data Source=InventoryDb;Engine=InMemory;");
        conn.Open();

        // 1. Create table schema
        auto cmdCreate = conn.CreateCommand();
        cmdCreate->SetCommandText("CREATE TABLE Items (Id INT, Name VARCHAR, Price INT)");
        cmdCreate->ExecuteNonQuery();

        // 2. Parameterized Insert (Recommended)
        auto cmdInsert = conn.CreateCommand();
        cmdInsert->SetCommandText("INSERT INTO Items (Id, Name, Price) VALUES (@id, @name, @price)");
        cmdInsert->GetParameters()->AddWithValue("@id", 101);
        cmdInsert->GetParameters()->AddWithValue("@name", "Bean Grinder");
        cmdInsert->GetParameters()->AddWithValue("@price", 75);
        cmdInsert->ExecuteNonQuery();

        // 3. Querying rows
        auto cmdSelect = conn.CreateCommand();
        cmdSelect->SetCommandText("SELECT Id, Name, Price FROM Items WHERE Price < @maxPrice");
        cmdSelect->GetParameters()->AddWithValue("@maxPrice", 100);

        auto reader = cmdSelect->ExecuteReader();
        while (reader->Read()) {
            int id = reader->GetInt32(0);
            String name = reader->GetString(1);
            int price = reader->GetInt32(2);

            Console::Write("Item: ");
            Console::Write(name);
            Console::Write(" costs $");
            Console::WriteLine(price);
        }

        conn.Close();
    } catch (const BasicException<char>& ex) {
        Console::Write("Database Error: ");
        Console::WriteLine(ex.What());
    }
}

STL vs DotNetDupe Comparison โš–๏ธ

DotNetDupe is designed to be more intuitive and less verbose than the standard C++ STL.

Sample Client and Test Code ๐Ÿงช

The repository includes DotNetDupeDemo (a sample console application) and DotNetDupeTests (unit tests) projects. These projects demonstrate how to integrate and use the DotNetDupe library. You can refer to their .vcxproj files for examples of how to configure your own projects to consume the DotNetDupe NuGet package.

API Reference ๐Ÿ“–

For detailed information on the available classes, methods, and their usage, please refer to the comprehensive API documentation for each class.

Namespace: DotNetDupe::WebAppCore::Builder

Classes

Class Description
WebApplicationBuilder Configures services and builds the web application host.
WebApplication Configures routing endpoints and hosts the HTTP listener.
WebAppServer Web server hosting static website content (HTML, CSS, images) and REST APIs.

Namespace: DotNetDupe::WebAppCore::Http

Classes

Class Description
HttpContext Encapsulates all HTTP-specific information about an individual HTTP request.
HttpRequest Represents the incoming HTTP request.
HttpResponse Represents the outgoing HTTP response.
Push Notifications (SSE & WebSockets) Server-Sent Events (SSE) streaming and WebSocket push notification support.

Namespace: DotNetDupe::WebAppCore::Controllers

Classes

Class Description
ControllerBase Base class for MVC/Web API style controllers.
ControllerRouteBuilder<T> Maps controller actions and automates JSON payload serialization.

Namespace: DotNetDupe::System

Classes

Class Description
Array<T> Provides methods for creating, manipulating, searching, and sorting arrays.
BitConverter Converts base data types to an array of bytes, and an array of bytes to base data types.
Buffer Manipulates arrays of primitive types.
Char Represents a character.
Console Provides methods for reading from and writing to the standard input, output, and error streams.
Convert Provides methods for converting a base data type to another base data type.
DaylightTime Defines the period of daylight saving time.
DateTimeOffset Represents a point in time, typically expressed as a date and time of day relative to UTC.
Environment Provides information about the current environment and platform.
Guid Represents a globally unique identifier (GUID).
Object Supports all classes in the .NET class hierarchy and provides low-level services to derived classes.
OperatingSystem Represents information about an operating system, such as the version and platform identifier.
Random Represents a pseudo-random number generator.
SmartPointer<T> A unified smart pointer supporting both unique and shared ownership.
String Represents text as a sequence of character code units.
TimeProvider Provides an abstraction for time.
TimeSpan Represents a time interval.
TimeZone Represents a time zone.
TimeZoneInfo Represents any time zone in the world.
Uri Provides an object representation of a uniform resource identifier (URI) and easy access to the parts of the URI.
UriBuilder Provides a convenient way to modify the contents of a Uri instance.
UriComponents Specifies the parts of a URI.
UriFormat Controls how URI information is escaped.
UriParser Parses a new URI scheme.
GenericUriParser A customizable parser for a hierarchical URI.
Version Represents the version number of an assembly, operating system, or the common language runtime.

Exceptions

Exception Description
Exception Represents errors that occur during application execution.
SystemException The base class for all predefined exceptions in the System namespace.
ArgumentException Represents errors that occur during argument processing.
ArgumentNullException The exception that is thrown when a null reference is passed to a method that does not accept it as a valid argument.
ArgumentOutOfRangeException Represents errors that occur when an argument is outside the allowable range of values.
ArithmeticException Represents errors in an arithmetic operation.
FormatException The exception that is thrown when the format of an argument is invalid.
NotImplementedException The exception that is thrown when a requested method or operation is not implemented.
OverflowException The exception that is thrown when an arithmetic, casting, or conversion operation in a checked context results in an overflow.

Interfaces

Interface Description
IClonable Defines a general-purpose mechanism for creating a new object that is a copy of the current object.
IComparable Defines a method that a value type or class implements to compare itself with another object of the same type.
IComparable<T> Defines a method that a value type or class implements to compare itself with another object of the same type.
IFormatProvider<T> Provides a mechanism for retrieving a formatting service for a specified type.
IServiceProvider Defines a mechanism for retrieving a service object (type-safe dependency resolution).

Namespace: DotNetDupe::System::Collections::Generic

Classes

Class Description
Dictionary<TKey, TValue> Represents a collection of keys and values.
List<T> Represents a strongly typed list of objects that can be accessed by index.

Namespace: DotNetDupe::System::Diagnostics

Classes

Class Description
EventLog Provides interaction with system event logs and writing diagnostic entries.
EtwLogReader Provides Event Tracing for Windows (ETW) and Linux Syslog channel enumeration, reading, and subscription listening.
SystemMetrics Queries system hardware telemetry metrics including CPU %, Memory load, Disk %, Network Mbps, and top processes.
ActiveUserSession Enumerates active and terminal user sessions across the system.
TerminalSession Enumerates active, disconnected, and remote desktop (RDP) Terminal Services sessions.
Process Provides access to local processes and enables you to start and stop local system processes.
Stopwatch Provides a set of methods and properties that you can use to accurately measure elapsed time.

Namespace: DotNetDupe::System::Text

Classes

Class Description
StringBuilder Represents a mutable string of characters.
TextEncoding Represents a character encoding.

Namespace: DotNetDupe::System::Utils

Classes

Class Description
StringConvert Provides static utility methods for converting strings between UTF-8 and UTF-16 representations.

Namespace: DotNetDupe::System::Collections::Generic

Classes

Class Description
List Represents a strongly typed list of objects that can be accessed by index.
Dictionary Represents a collection of keys and values.
Queue Represents a First-In-First-Out (FIFO) collection of instances.
Stack Represents a Last-In-First-Out (LIFO) collection of instances.
HashSet Represents a set of unique values using a hash table.
SortedDictionary Represents a collection of key/value pairs that are sorted on the key.
SortedSet Represents a collection of objects that is maintained in sorted order.
LinkedList Represents a doubly linked list.
PriorityQueue Represents a collection of items that have a value and a priority.

Namespace: DotNetDupe::System::Collections::Concurrent

Classes

Class Description
ConcurrentDictionary Thread-safe key-value collection for concurrent operations.
ConcurrentQueue Thread-safe First-In-First-Out (FIFO) collection.
ConcurrentStack Thread-safe Last-In-First-Out (LIFO) collection.
ConcurrentBag Thread-safe unordered collection of objects.
BlockingCollection Thread-safe collection for blocking producer-consumer workflows.

Namespace: DotNetDupe::System::Text::Json

Classes

Class Description
JsonSerializer Provides functionality to serialize objects to JSON and deserialize JSON to objects.

Namespace: DotNetDupe::System::IO

Classes

Class Description
Path A class for path-related operations.
File Provides static methods for the creation, copying, deletion, moving, and opening of a single file.
FileStream Provides a Stream for a file, supporting both synchronous and asynchronous read and write operations.
Stream Provides a generic view of a sequence of bytes.
TextReader Represents a reader that can read a sequential series of characters.
TextWriter Represents a writer that can write a sequential series of characters.
StringReader Implements a TextReader that reads from a string.
StringWriter Implements a TextWriter for writing information to a string.

Exceptions

Exception Description
IOException The exception that is thrown when an I/O error occurs.

Interfaces

Interface Description
IDisposable Provides a mechanism for releasing unmanaged resources.

Namespace: DotNetDupe::System::Net

Classes

Class Description
Dns Provides simple domain name resolution functionality.

Namespace: DotNetDupe::System::Net::Sockets

Classes

Class Description
Socket A wrapper around standard native socket APIs.
NetworkStream Provides the underlying stream of data for network access.
TcpClient Provides client connections for TCP network services.
TcpListener Listens for connections from TCP network clients.
UdpClient Provides UDP datagram sockets.

Namespace: DotNetDupe::System::Net::Security

Classes

Class Description
SslStream Provides a stream that uses the SSL/TLS security protocol to secure communication.

Namespace: DotNetDupe::System::Net::Http

Classes

Class Description
HttpClient Sends HTTP requests and receives HTTP responses from a resource identified by a URI.
RestClient Represents a strongly-typed REST client that simplifies resource-oriented Web API interactions by automatically serializing/deserializing payloads to and from C++ structures.
HttpRequestMessage Represents an HTTP request message.
HttpResponseMessage Represents an HTTP response message including the status code and data.
HttpContent Abstract class representing an HTTP entity body and content headers.
StringContent Provides HTTP content based on a string.
ByteArrayContent Provides HTTP content based on a byte array.
HttpMethod Represents an HTTP method.

Namespace: DotNetDupe::System::Security::Principal

Classes

Class Description
UserPrincipal Enumerates system user accounts (Windows/Linux) and inspects user classification, groups, and security permissions.

Namespace: DotNetDupe::System::Security::Cryptography

Classes

Class Description
HMACSHA256 Computes a Hash-based Message Authentication Code (HMAC) using the SHA256 hash function.

Namespace: DotNetDupe::System::Security::Cryptography::X509Certificates

Classes

Class Description
X509Certificate2 Represents an X.509 certificate and private key loaded from PEM files.

Namespace: DotNetDupe::System::IdentityModel::Tokens::Jwt

Classes

Class Description
JWTToken Represents a JSON Web Token containing a header block, claims, and signature.

Namespace: DotNetDupe::System::Data::SqlClient

Classes

Class Description
SqlConnection Represents an open connection to a database.
SqlCommand Represents an SQL statement to execute against a database.
SqlDataReader Provides a way of reading a forward-only stream of rows from a database.
SqlParameter Represents a parameter for an SQL command.

Namespace: DotNetDupe::System::Threading

Classes

Class Description
Thread Creates and controls a thread, sets its priority, and gets its status.
ThreadPool Provides a pool of threads that can be used to execute tasks, post work items, and more.
Task Represents an asynchronous operation.
WaitHandle Abstract base class for synchronization objects.
EventWaitHandle Represents a thread synchronization event.
ManualResetEvent Notifies one or more waiting threads that an event has occurred.
AutoResetEvent Notifies a waiting thread that an event has occurred.
Mutex A synchronization primitive that can also be used for inter-process synchronization.
Semaphore Limits the number of threads that can access a resource or pool of resources concurrently.
SemaphoreSlim A lightweight alternative to Semaphore.
CriticalSection A wrapper around a recursive mutex for critical sections.
Interlocked Provides atomic operations for variables that are shared by multiple threads.
Lock<T> RAII mechanism for synchronization objects.

Exceptions

Exception Description
ThreadStateException The exception that is thrown when a Thread is in an invalid ThreadState for the method call.
ThreadInterruptedException The exception that is thrown when a Thread is interrupted while it is in a waiting state.
SynchronizationLockException The exception that is thrown when a method requires the caller to own the lock on a given Monitor, and the method is invoked by a caller that does not own that lock.
AbandonedMutexException The exception that is thrown when one thread acquires a Mutex object that another thread has abandoned by exiting without releasing it.
WaitHandleCannotBeOpenedException The exception that is thrown when an attempt is made to open a system mutex, semaphore, or event wait handle that does not exist.
SemaphoreFullException The exception that is thrown when the Release method is called on a semaphore whose count is already at the maximum.

Namespace: DotNetDupe::Extensions::DependencyInjection

Classes

Class Description
ServiceCollection Accumulates service descriptors and builds the service provider.
ServiceProvider The concrete implementation of the dependency injection container.
ServiceScope Represents a lifetime scope for scoped services.
ServiceScopeFactory Creates instances of ServiceScope, which are used to resolve scoped dependencies.

Interfaces

Interface Description
IServiceCollection A collection of service descriptors.
IServiceScope Represents the lifetime of a scoped service.
IServiceScopeFactory Defines a factory for creating service scopes.

Namespace: DotNetDupe::Extensions::Logging

Classes

Class Description
LoggerFactory The concrete implementation of the logging factory.
Logger<T> A generic template wrapper for class-specific category logging.
ConsoleLoggerProvider Renders structured console outputs (Plain or JSON format).
FileLoggerProvider Writes structured log records thread-safely to a file.

Interfaces

Interface Description
ILogger Defines the entry interface for logging messages.
ILoggerOf<T> Represents a template logging category interface.
ILoggerProvider Defines a provider factory for creating loggers.
ILoggerFactory Manages logging providers and creates category loggers.

Project Status ๐Ÿšง

DotNetDupe is currently under active development. We are continuously working on expanding the API coverage and improving stability.

Contributions ๐Ÿ‘‹

Contributions to the DotNetDupe project are highly welcome! Whether it's bug reports, feature requests, code contributions, or documentation improvements, your help is invaluable. Please refer to GitHub's general contributing guidelines for more information on how to get started.

CI/CD Pipeline ๐Ÿš€

This repository uses GitHub Actions to automate the build, test, and release process.

Workflow Details

  • Build & Test: Every push to main and all pull requests trigger a full build (Debug & Release) and execution of all unit tests.
  • NuGet Release: Pushing a tag (e.g., v1.0.0) triggers the creation and publishing of the NuGet package to nuget.org.

How to Release

  1. Update the version in DotNetDupe.nuspec.
  2. Commit and push the changes.
  3. Create and push a new tag:
    git tag v1.0.0
    git push origin v1.0.0
    
    Note: Requires NUGET_API_KEY to be set in GitHub repository secrets.

License ๐Ÿ“„

This project is licensed under the MIT License. See the LICENSE file for details.

Generated Content ๐Ÿค–

This project is a unique blend of manual craftsmanship and AI-powered development. While the initial core components were meticulously crafted by hand, the majority of the remaining code, including many classes, methods, and their corresponding unit tests, were generated with the assistance of Gemini, a large language model. This approach highlights the potential of generative AI in accelerating software development from scratch.

Contact ๐Ÿ“ง

For questions or support, please open an issue on the GitHub repository or contact sudheeshps@gmail.com.

Product Compatible and additional computed target framework versions.
native native is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
5.0.5 86 10/26/2026
5.0.4 99 10/15/2026
5.0.3 111 10/2/2026
5.0.2 107 9/29/2026
5.0.1 97 9/29/2026
5.0.0 100 9/28/2026
4.0.7 119 9/10/2026
4.0.6 119 9/10/2026
4.0.5 108 9/9/2026
4.0.4 109 9/9/2026
4.0.3 171 8/20/2026
4.0.2 116 8/20/2026
4.0.1 129 8/17/2026
4.0.0 127 8/15/2026
3.0.6 127 8/6/2026
3.0.5 132 8/6/2026
3.0.4 121 8/5/2026
3.0.2 129 8/5/2026
3.0.1 140 6/20/2026
3.0.0 128 5/31/2026
Loading failed

Added database support, authentication/authorization, secure HTTP (SSL) and JWT token handling, a dependency injection framework, WebApplication and RestClient (supporting PUT/DELETE), a Logger, enhanced WSL NuGet documentation, and added usage samples to the class API documentation.