Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ dotnet_diagnostic.IDE0301.severity = none # simplify collection initialization
dotnet_diagnostic.IDE0053.severity = none # expression body lambda
dotnet_diagnostic.IDE0046.severity = none # simplify if(s) - conditional operator
dotnet_diagnostic.IDE0305.severity = none # [, ...] instead of .ToArray()
dotnet_diagnostic.IDE0306.severity = none # Use collection expressions


# namespace declaration
Expand Down
63 changes: 0 additions & 63 deletions .gitattributes

This file was deleted.

5 changes: 2 additions & 3 deletions .github/workflows/Tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ jobs:
fail-fast: false
matrix:
platform: [ubuntu-latest, windows-latest, macos-latest]
project: [tests/Sharpify.Tests/Sharpify.Tests.csproj, tests/Sharpify.CommandLineInterface.Tests/Sharpify.CommandLineInterface.Tests.csproj]
uses: dusrdev/actions/.github/workflows/reusable-dotnet-test-mtp.yaml@main
with:
platform: ${{ matrix.platform }}
dotnet-version: 9.0.x
test-project-path: ${{ matrix.project }}
dotnet-version: 10.0.x
test-project-path: tests/Sharpify.Tests/Sharpify.Tests.csproj
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# CHANGELOG

* Only .NET 10+ support.
* Some computed properties in `BufferWrapper{T}` were made `readonly` to hint the compiler to not create defensive copies.
* `PersistentDictionary` in all of its variants have been removed - used `ArrowDb` instead.
* `SerializableObject<T>`, `MonitoredSerializableObject<T>` and `ThreadSafe<T>` have all been combined into `Synchronized<T>` which is much simpler, more performant. But can be more manual as it isn't coupled with `File.IO`. Instead it provides a delegate that can be provided and called on update.
* `Collections.IsNullOrEmpty` and all the other alias functions for `CollectionsMarshal` have been removed.
* `Utils` subclasses have been flattened and all the contents will reside directly in `Utils`.
* `Strings.FormatBytes` have been removed
* `Path` utilities were also removed - use `AppContext` instead.
* `String.IsNullOrEmpty|IsNullOrWhiteSpace|Concat` were also removed to enforce build-in language features.
* `TryConvertFromTo32` was also removed - `int.Parse|TryParse` are more than fast enough now.
* A struct `PooledArrayOwner{T}` was added to rent arrays from `ArrayPool{T}` without additional penalties.
* Extensions to match were added to any `ArrayPool{T}` including `Shared`, they allow you to get the owner and the array at the same time. `using var owner = ArrayPool{T}.Shared.Rent(minLength, out T[] array);`
* You can then proceed to use `BufferWrapper{T}.Create(array)` to get an `IBufferWriter` implementation over it.
63 changes: 13 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,38 @@
# Sharpify

A collection of high performance language extensions for C#, fully compatible with NativeAOT

## ⬇ Installation

[![Nuget](https://img.shields.io/nuget/dt/Sharpify?label=Sharpify%20Nuget%20Downloads)](https://www.nuget.org/packages/Sharpify/)
> dotnet add package Sharpify

[![Nuget](https://img.shields.io/nuget/dt/Sharpify.Data?label=Sharpify.Data%20Nuget%20Downloads)](https://www.nuget.org/packages/Sharpify.Data/)
> dotnet add package Sharpify.Data

* `Sharpify.Data` is deprecated and will no longer be maintained. Refer to [ArrowDb](https://github.com/dusrdev/ArrowDb) for a superior alternative.

[![Nuget](https://img.shields.io/nuget/dt/Sharpify.CommandLineInterface?label=Sharpify.CommandLineInterface%20Nuget%20Downloads)](https://www.nuget.org/packages/Sharpify.CommandLineInterface/)
> dotnet add package Sharpify.CommandLineInterface
[![NuGet](https://img.shields.io/nuget/v/Sharpify.svg?style=flat-square)](https://www.nuget.org/packages/Sharpify)
[![NuGet Downloads](https://img.shields.io/nuget/dt/Sharpify?style=flat&label=Downloads)](https://www.nuget.org/packages/Sharpify)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](License.txt)
[![.NET](https://img.shields.io/badge/.NET-10.0-512BD4?style=flat-square)](https://dotnet.microsoft.com/en-us/download/dotnet/10.0)

## Sharpify - Base package

`Sharpify` is a package mainly intended to extend the core language using high performance implementations. The other 2 packages uses `Sharpify` as a dependency. But its core features can be useful in a variety of applications by themselves.
A collection of high performance language extensions for C#, fully compatible with NativeAOT

* ⚡ Fully Native AOT compatible
* 🤷 `Either<T0, T1>` - Discriminated union object that forces handling of both cases
* 🦾 Flexible `Result` type that can encapsulate any other type and adds a massage options and a success or failure status. Flexible as it doesn't require any special handling to use (unlike `Either`)
* 🏄 Wrapper extensions that simplify use of common functions and advanced features from the `CollectionsMarshal` class
* `Routine` and `AsyncRoutine` bring the user easily usable and configurable interval based background job execution.
* `PersistentDictionary` and derived types are super lightweight and efficient serializable dictionaries that are thread-safe and work amazingly for things like configuration files.
* `SortedList<T>` bridges the performance of `List` and order assurance of `SortedSet`
* `PersistentDictionary` and variants provide all simple database needs, with perfected performance and optimized concurrency.
* `SerializableObject` and the `Monitored` variant allow persisting an object to the disk, and elegantly synchronizing modifications.
* `Synchronized<T>` is a thread-safe object owner with an optional delegate that can be executed on update.
* 💿 `StringBuffer` enables zero allocation, easy to use appending buffer for creation of strings in hot paths.
* `RentedBufferWriter{T}` is an allocation friendly alternative to `ArrayBufferWriter{T}` for hot paths.
* `PooledArrayOwner{T}` is struct based alternative to `IMemoryOwner<T>` with extensions built into the `ArrayPool<T>` class.
* `BufferWrapper{T}` is a ref struct implementation of `IBufferWriter{T}` that wraps a `Span<T>`.
* A 🚣🏻 boat load of extension functions for all common types, bridging ease of use and performance.
* `Utils.DateAndTime`, `Utils.Env`, `Utils.Math`, `Utils.Strings` and `Utils.Unsafe` provide uncanny convenience at maximal performance.
* 🧵 `ThreadSafe<T>` makes any variable type thread-safe
* A bunch of utils in `Utils` class.
* 🔐 `AesProvider` provides access to industry leading AES-128 encryption with virtually no setup
* 🏋️ High performance optimized alternatives to core language extensions
* 🎁 More added features that are not present in the core language
* ❗ Static inner exception throwers guide the JIT to further optimize the code during runtime.
* 🫴 Focus on giving the user complete control by using flexible and common types, and resulting types that can be further used and just viewed.

For more information check [inner directory](src/Sharpify/README.md).

## Sharpify.Data

`Sharpify.Data` is an extension package, that should be installed on-top of `Sharpify` and adds a high performance persistent key-value-pair database, utilizing [MemoryPack](https://github.com/Cysharp/MemoryPack). The database support multiple types in the same file, 2 stage AES encryption (for whole file and per-key). Filtering by type, Single or Array value per key, and more...

* `Database` is the base type for the data base, it is key-value-pair based local database - saved on disk.
* `IDatabaseFilter<T>` is an interface which acts as an alternative to `DbContext` and provides enhanced type safety for contexts.
* `MemoryPackDatabaseFilter<T>` is an implementation which focuses on types that implement `IMemoryPackable<T>` from `MemoryPack`.
* `FlexibleDatabaseFilter<T>` is an implementation focusing on types which need custom serialization logic. To use this, you type `T` will need to implement `IFilterable<T>` which has methods for serialization and deserialization of single `T` and `T[]`. If you can choose to implement only one of the two.
* **Concurrency** - `Database` uses highly performant synchronous concurrency models and is completely thread-safe.
* **Disk Usage** - `Database` tracks inner changes and skips serialization if no changes occurred, enabling usage of periodic serialization without resource waste.
* **GC Optimization** - `Database` heavily uses pooling for encryption, decryption, type conversion, serialization and deserialization to minimize GC overhead, very rarely does it allocate single-use memory and only when absolutely necessary.
* **HotPath APIs** - `Database` is optimized for hot paths, as such it provides a number of APIs that specifically combine features for maximum performance and minimal GC overhead. Like the `TryReadToRentedBuffer<T>` methods which is optimized for adding data to a table.
* **Runtime Optimization** - Upon initialization, `Database` chooses specific serializers and deserializers tailored for specific configurations, minimizing the amount of runnable code during runtime that would've been wasted on different checks.
## ⬇ Installation

For more information check [inner directory](src/Sharpify.Data/README.md).
> dotnet add package Sharpify

## Sharpify.CommandLineInterface

`Sharpify.CommandLineInterface` is a standalone package that adds a high performance, reflection free and `AOT-ready` framework for creating command line and embedded interfaces

* Maintenance friendly model that depends on classes that implement `Command` or `SynchronousCommand`
* `Arguments` is an abstraction layer over the inputs that validate during runtime according to user needs via convenient APIs.
* Configuration using a fluent builder pattern.
* Configurable output and input pipes, enable usage outside of `Console` apps, supporting embedded use in any application.
* Automatic and structured general and command-specific help text.
* Configurable error handling with defaults.
* Super lightweight
It was moved to its own repo [Sharpify.CommandLineInterface](https://github.com/dusrdev/Sharpify.CommandLineInterface)

For more information check [inner directory](src/Sharpify.CommandLineInterface/README.md)
##

## Methodology

Expand Down
10 changes: 6 additions & 4 deletions Sharpify.slnx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<Solution>
<Project Path="src/Sharpify.CommandLineInterface/Sharpify.CommandLineInterface.csproj" />
<Project Path="src/Sharpify/Sharpify.csproj" />
<Project Path="tests/Sharpify.CommandLineInterface.Tests/Sharpify.CommandLineInterface.Tests.csproj" />
<Project Path="tests/Sharpify.Tests/Sharpify.Tests.csproj" />
<Folder Name="/src/">
<Project Path="src/Sharpify/Sharpify.csproj" />
</Folder>
<Folder Name="/tests/">
<Project Path="tests/Sharpify.Tests/Sharpify.Tests.csproj" />
</Folder>
</Solution>
16 changes: 16 additions & 0 deletions src/Sharpify/CHANGELOG.md → VERSIONS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# CHANGELOG

## v3.0.0

* Only .NET 10+ support.
* Some computed properties in `BufferWrapper{T}` were made `readonly` to hint the compiler to not create defensive copies.
* `PersistentDictionary` in all of its variants have been removed - used `ArrowDb` instead.
* `SerializableObject<T>`, `MonitoredSerializableObject<T>` and `ThreadSafe<T>` have all been combined into `Synchronized<T>` which is much simpler, more performant. But can be more manual as it isn't coupled with `File.IO`. Instead it provides a delegate that can be provided and called on update.
* `Collections.IsNullOrEmpty` and all the other alias functions for `CollectionsMarshal` have been removed.
* `Utils` subclasses have been flattened and all the contents will reside directly in `Utils`.
* `Strings.FormatBytes` have been removed
* `Path` utilities were also removed - use `AppContext` instead.
* `String.IsNullOrEmpty|IsNullOrWhiteSpace|Concat` were also removed to enforce build-in language features.
* `TryConvertFromTo32` was also removed - `int.Parse|TryParse` are more than fast enough now.
* A struct `PooledArrayOwner{T}` was added to rent arrays from `ArrayPool{T}` without additional penalties.
* Extensions to match were added to any `ArrayPool{T}` including `Shared`, they allow you to get the owner and the array at the same time. `using var owner = ArrayPool{T}.Shared.Rent(minLength, out T[] array);`
* You can then proceed to use `BufferWrapper{T}.Create(array)` to get an `IBufferWriter` implementation over it.

## v2.5.0

* Updated to support .NET 9.0 and optimized certain methods to use .NET 9 specific API's wherever possible.
Expand Down
16 changes: 0 additions & 16 deletions demos/Calc/Calc.sln

This file was deleted.

38 changes: 0 additions & 38 deletions demos/Calc/Calc/Calc.csproj

This file was deleted.

25 changes: 0 additions & 25 deletions demos/Calc/Calc/Commands/AddCommand.cs

This file was deleted.

25 changes: 0 additions & 25 deletions demos/Calc/Calc/Commands/DivideCommand.cs

This file was deleted.

25 changes: 0 additions & 25 deletions demos/Calc/Calc/Commands/MultiplyCommand.cs

This file was deleted.

35 changes: 0 additions & 35 deletions demos/Calc/Calc/Commands/SubtractCommand.cs

This file was deleted.

Loading