ktsu.Abstractions 1.0.2

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package ktsu.Abstractions --version 1.0.2
                    
NuGet\Install-Package ktsu.Abstractions -Version 1.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="ktsu.Abstractions" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ktsu.Abstractions" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="ktsu.Abstractions" />
                    
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 ktsu.Abstractions --version 1.0.2
                    
#r "nuget: ktsu.Abstractions, 1.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 ktsu.Abstractions@1.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=ktsu.Abstractions&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=ktsu.Abstractions&version=1.0.2
                    
Install as a Cake Tool

status: draft title: ktsu.Abstractions description: A library providing a consistent set of interfaces for compression, encryption, hashing, obfuscation, serialization, and filesystem access. tags:

  • abstractions
  • .net
  • csharp
  • provider pattern
  • dependency injection
  • serialization
  • compression
  • encryption
  • hashing
  • obfuscation

ktsu.Abstractions

A small, focused library of interfaces that define a consistent API for common cross-cutting concerns:

  • Compression: ICompressionProvider
  • Encryption: IEncryptionProvider
  • Hashing: IHashProvider
  • Obfuscation: IObfuscationProvider
  • Serialization: ISerializationProvider
  • Filesystem: IFileSystemProvider (extends System.IO.Abstractions.IFileSystem for testable IO)

Designed for framework-agnostic usage and easy dependency injection. Ships with an analyzer that enforces consistent enum ordering across the codebase.

Install

dotnet add package ktsu.Abstractions

Or add a project reference if you keep the interfaces in a shared solution.

Quickstart

Implement the interfaces in your application or infrastructure layer and register them with your DI container.

using System.Text.Json;
using ktsu.Abstractions;

public sealed class JsonSerializationProvider : ISerializationProvider
{
    public string Serialize<T>(T obj) => JsonSerializer.Serialize(obj);
    public string Serialize(object obj, Type type) => JsonSerializer.Serialize(obj, type);
    public T Deserialize<T>(string data) => JsonSerializer.Deserialize<T>(data)!;
    public object Deserialize(string data, Type type) => JsonSerializer.Deserialize(data, type)!;

    public Task<string> SerializeAsync<T>(T obj, CancellationToken cancellationToken = default)
        => Task.FromResult(Serialize(obj));
    public Task<string> SerializeAsync(object obj, Type type, CancellationToken cancellationToken = default)
        => Task.FromResult(Serialize(obj, type));
    public Task<T> DeserializeAsync<T>(string data, CancellationToken cancellationToken = default)
        => Task.FromResult(Deserialize<T>(data));
    public Task<object> DeserializeAsync(string data, Type type, CancellationToken cancellationToken = default)
        => Task.FromResult(Deserialize(data, type));
}

Register with DI (example shown with Microsoft.Extensions.DependencyInjection):

using ktsu.Abstractions;
using Microsoft.Extensions.DependencyInjection;

IServiceCollection services = new ServiceCollection();
services.AddSingleton<ISerializationProvider, JsonSerializationProvider>();

IServiceProvider provider = services.BuildServiceProvider();
ISerializationProvider serializer = provider.GetRequiredService<ISerializationProvider>();

string json = serializer.Serialize(new { Message = "Hello" });

For file system access, depend on IFileSystemProvider to get testable IO via System.IO.Abstractions:

using ktsu.Abstractions;
using System.IO.Abstractions;

public sealed class MyService
{
    private readonly IFileSystemProvider fileSystem;
    public MyService(IFileSystemProvider fileSystem) => this.fileSystem = fileSystem;

    public void WriteText(string path, string content)
    {
        fileSystem.File.WriteAllText(path, content);
    }
}

Interfaces overview

  • ICompressionProvider: Compress, Decompress, CompressAsync, DecompressAsync
  • IEncryptionProvider: Encrypt, Decrypt, EncryptAsync, DecryptAsync, GenerateKey, GenerateIV
  • IHashProvider: hashing abstraction surface (implementations define concrete algorithms)
  • IObfuscationProvider: Obfuscate, Deobfuscate, async counterparts, with optional parameters
  • ISerializationProvider: Serialize/Deserialize for generic and non-generic, sync/async
  • IFileSystemProvider: System.IO.Abstractions.IFileSystem implementation for DI-friendly IO

Related enums for common options are provided in ktsu.Abstractions.Models:

  • Compression: CompressionType
  • Encryption: EncryptionType
  • Hashing: HashType
  • Obfuscation: ObfuscationType
  • Filesystem: FileSystemType

Analyzer

An included analyzer enforces enum ordering across the codebase:

  • Diagnostic ID: KTSU001
  • Rule: If present, None = 0 must be declared first; remaining members must be in alphabetical order, without explicit numeric values.

Why use these abstractions?

  • Consistency: A single, predictable surface across implementations
  • Testability: Swap implementations and mock easily, especially for filesystem
  • Separation of concerns: Keep app code free of vendor-specific details

Contributing

  • Fork the repo and create a feature branch
  • Implement or refine providers/analyzers and add tests
  • Open a pull request
  • Project: ktsu-dev/Abstractions
  • License: see LICENSE.md
  • Changelog: see CHANGELOG.md and LATEST_CHANGELOG.md
  • Authors: see AUTHORS.md
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (16)

Showing the top 5 NuGet packages that depend on ktsu.Abstractions:

Package Downloads
ktsu.SerializationProviders.SystemTextJson

A collection of serialization providers implementing ktsu.Abstractions.ISerializationProvider for popular .NET JSON libraries including Newtonsoft.Json and System.Text.Json.

ktsu.SerializationProviders.NewtonsoftJson

A collection of serialization providers implementing ktsu.Abstractions.ISerializationProvider for popular .NET JSON libraries including Newtonsoft.Json and System.Text.Json.

ktsu.HashProviders.SHA256

A collection of serialization providers implementing ktsu.Abstractions.ISerializationProvider for popular .NET JSON libraries including Newtonsoft.Json and System.Text.Json.

ktsu.HashProviders.MD5

A collection of serialization providers implementing ktsu.Abstractions.ISerializationProvider for popular .NET JSON libraries including Newtonsoft.Json and System.Text.Json.

ktsu.CompressionProviders.Gzip

A collection of serialization providers implementing ktsu.Abstractions.ISerializationProvider for popular .NET JSON libraries including Newtonsoft.Json and System.Text.Json.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.8 107 8/15/2025
1.0.7 181 8/12/2025
1.0.6 128 8/11/2025
1.0.5 123 8/11/2025
1.0.4 123 8/11/2025
1.0.3 127 8/11/2025
1.0.2 122 8/10/2025
1.0.1 124 8/10/2025

## v1.0.2 (patch)

Changes since v1.0.1:

- Remove EnumOrderingAnalyzer project and related files from the solution, streamlining the project structure and eliminating unused analyzers. ([@matt-edmondson](https://github.com/matt-edmondson))
## v1.0.1 (patch)

Changes since v1.0.0:

- Add detailed README for ktsu.Abstractions library, outlining interfaces for compression, encryption, hashing, obfuscation, serialization, and filesystem access. Include installation instructions, quickstart examples, and contributing guidelines. ([@matt-edmondson](https://github.com/matt-edmondson))
- Remove obsolete abstraction models for compression, encryption, hashing, obfuscation, and filesystem types, along with global usings. This cleanup streamlines the project structure. ([@matt-edmondson](https://github.com/matt-edmondson))
## v1.0.0 (major)

- Initial commit ([@matt-edmondson](https://github.com/matt-edmondson))
- Remove outdated files and update project references to reflect the new repository name 'Abstractions'. Set version to 1.0.0 and clean up changelog, README, and tags. ([@matt-edmondson](https://github.com/matt-edmondson))