LayerZero.Tools 1.0.1

dotnet add package LayerZero.Tools --version 1.0.1
                    
NuGet\Install-Package LayerZero.Tools -Version 1.0.1
                    
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="LayerZero.Tools" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LayerZero.Tools" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="LayerZero.Tools" />
                    
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 LayerZero.Tools --version 1.0.1
                    
#r "nuget: LayerZero.Tools, 1.0.1"
                    
#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 LayerZero.Tools@1.0.1
                    
#: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=LayerZero.Tools&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=LayerZero.Tools&version=1.0.1
                    
Install as a Cake Tool

πŸ“¦ 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, bool
    • DateTime, DateOnly, TimeOnly
    • enum types (case-insensitive)
    • Complex objects via JsonSerializer.Deserialize<T>()
  • Optional strict mode β€” throws on failure
  • Optional format and CultureInfo for date/time types
  • Integrates with RuneGuard extensions 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, and JsonSerializer.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 validation
  • ToDictionarySafe() with optional overwrite
  • DistinctSafe() with optional custom comparer
  • FallbackIfEmpty() for graceful default population

Built to prevent:

  • ArgumentNullException
  • IndexOutOfRangeException
  • 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>> and Func<CancellationToken, Task<T>>
  • Includes void-returning task support
  • Based on TaskFactory to 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 Result or .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 GET and POST requests
  • 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

πŸ§ͺ 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 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 using WebOptimizer.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 222 6/13/2025