LayerZero.Tools
2.0.0
dotnet add package LayerZero.Tools --version 2.0.0
NuGet\Install-Package LayerZero.Tools -Version 2.0.0
<PackageReference Include="LayerZero.Tools" Version="2.0.0" />
<PackageVersion Include="LayerZero.Tools" Version="2.0.0" />
<PackageReference Include="LayerZero.Tools" />
paket add LayerZero.Tools --version 2.0.0
#r "nuget: LayerZero.Tools, 2.0.0"
#:package LayerZero.Tools@2.0.0
#addin nuget:?package=LayerZero.Tools&version=2.0.0
#tool nuget:?package=LayerZero.Tools&version=2.0.0
π¦ Installation
Planned NuGet package:
dotnet add package LayerZero.Tools
SygilParser
SygilParser is a lightweight, guard-backed type parser for .NET that unifies the handling of primitives, enums, datetime formats, and structured data.
Designed for systems where input cannot be trusted and parsing must be intentional.
Part of the LayerZero.Tools suite β focused on foundational, intentional .NET tooling.
π Features
.Parse<T>()extension method for unified type parsing- Supports:
string,int,long,decimal,boolDateTime,DateOnly,TimeOnlyenumtypes (case-insensitive)- Complex objects via
JsonSerializer.Deserialize<T>()
- Optional
strictmode β throws on failure - Optional
formatandCultureInfofor date/time types - Integrates with
RuneGuardextensions for input validation - Minimal dependencies and zero allocations on valid fast-paths
π§ͺ Example
using LayerZero.Tools.Sigil;
"42".Parse<int>(); // 42
"2024-06-01".Parse<DateTime>(); // DateTime object
"ACTIVE".Parse<Status>(); // Enum parsed case-insensitive
"{"id":1}".Parse<MyObject>(); // JSON to object
"bad".Parse<int>(strict: false); // returns default(int)
"invalid".Parse<DayOfWeek>(strict: true); // throws
"15/03/2024".Parse<DateOnly>(format: "dd/MM/yyyy");
β‘ Performance
Benchmark summary from BenchmarkDotNet:
| Type | Mean | Allocations |
|---|---|---|
int.Parse |
~9 ns | 0 B |
DateTime.Parse |
~65 ns | 0 B |
enum.Parse |
~30 ns | 0 B |
Json β object |
~250 ns | ~96 B |
| Invalid fallback | 10β30x slower (try/catch triggered) |
Use strict: false to avoid exceptions during batch parse.
βοΈ Why SygilParser Exists
In .NET, parsing is fragmented:
int.Parse,bool.TryParse,Enum.Parse,DateTime.ParseExact, andJsonSerializer.Deserialize
Each uses different semantics, error handling, and cultural assumptions.
SygilParser brings type parsing under a single, guarded construct β
for developers who want clarity, predictability, and fallback options by design.
βThe shape of a system begins with the clarity of a single stroke.β
π§° SafeLinQ
SafeLinQ provides defensive, expressive alternatives to common LINQ operations in .NET, guarding against nulls, empty sources, and missing elements.
Part of the LayerZero.Tools suite β built for resilience and clarity in everyday collection usage.
π Features
ElementAtSafe()with index bounds validationToDictionarySafe()with optional overwriteDistinctSafe()with optional custom comparerFallbackIfEmpty()for graceful default population
Built to prevent:
ArgumentNullExceptionIndexOutOfRangeException- Silent LINQ misbehavior (e.g.,
.First()on empty sources)
π§ͺ Example
using LayerZero.Tools.Linq;
var list = new[] { "alpha", "beta", "gamma" };
list.ElementAtSafe(1); // "beta"
list.ElementAtSafe(10); // null (safe fallback)
list.ToDictionarySafe(x => x.Length, false);
// { 5: "alpha", 4: "beta" } β keeps first occurrence
list.DistinctSafe(); // distinct items
list.FallbackIfEmpty(() => "default"); // yields "default" if empty
βοΈ Why SafeLinQ Exists
In standard LINQ, silent failures and non-obvious exceptions are common:
source.First(); // throws on empty
source.ElementAt(99); // throws on out-of-range
source.ToDictionary(); // throws on duplicate keys
SafeLinQ addresses these issues by:
- Adding precondition checks
- Allowing graceful degradation
- Preserving caller intent
βοΈ GeasMaster
GeasMaster is a synchronous execution harness for asynchronous .NET tasks. Useful when async code must run in blocking contexts β safely, consistently, and without ConfigureAwait chaos.
Part of the LayerZero.Tools suite β focused on deterministic control and guard-backed execution.
π Features
RunSync<T>()to execute async functions synchronously and retrieve result- Overloads for both
Func<Task<T>>andFunc<CancellationToken, Task<T>> - Includes void-returning task support
- Based on
TaskFactoryto avoid deadlocks in UI or legacy contexts
π§ͺ Example
using LayerZero.Tools.Runtime;
var result = GeasMaster.RunSync(() => MyAsyncMethod());
GeasMaster.RunSync(async ct =>
{
await DoSomethingAsync(ct);
});
βοΈ Why GeasMaster Exists
Async/await is ideal β but legacy codebases, ASP.NET constructors, or sync APIs occasionally require a deterministic, blocking call.
GeasMaster gives you this capability safely:
- No deadlocks from
Resultor.Wait() - Controlled sync execution via
TaskFactory - Minimal ceremony, full control
βA task without form is a thread unbound.β
π LeyLineCaller
LeyLineCaller is a minimalistic HTTP client wrapper with optional authentication headers, built-in sync/async handling, and typed parsing β ideal for internal APIs or automation tools.
π Features
- Built-in support for
GETandPOSTrequests - Sync and async execution support (via
GeasMaster) - Optional authentication via
SigilBinder - Smart response parsing with support for:
- JSON (via
SygilParser) - Binary streams (as
EchoShard) - Text/plain and fallback formats
- JSON (via
π§ͺ Example
var caller = new LeyLineCaller(myTokenBinder);
var result = caller.Get<MyDto>("https://api.myapp.com/data");
await caller.PostAsync<MyResponse>("/submit", new { id = 42 });
βοΈ Why LeyLineCaller Exists
- HttpClient is powerful but verbose
- Most HTTP wrappers are overkill or opinionated
- Sync scenarios are needed in CLI tools or scripting environments
LeyLineCaller balances minimalism and power:
- Transparent async/sync bridging
- Typed deserialization with safety
- Built for internal systems where speed matters
πΎ License
MIT
π¨ Author
Crafted by [RuneForgePrime]
Part of the LayerZero.Tools initiative.
βThe line is open. Let the ley energies flow.β
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 was computed. 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. |
-
net8.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on LayerZero.Tools:
| Package | Downloads |
|---|---|
|
LayerZero.Tools.Web
Convention-based dynamic JS/CSS bundling and injection system for ASP.NET Core. |
|
|
LayerZero.Tools.Routing
Convention-driven ASP.NET Core routing utilities with minimal dependencies β includes namespace-based route generation, versioning and feature segregation, startup-time resolution, and selective route overrides. |
GitHub repositories
This package is not used by any popular GitHub repositories.