Skip to content

goealabs/dotnet-bedrock

Repository files navigation

GoeaLabs.Bedrock

GitHub GitHub release (latest SemVer) Nuget (with prereleases)

Project Description

A collection of general purpose helper methods used by my other libraries.

Compatibility

Compatible with .NET6 and higher, includes .NET7 build.

API(s)

  • Array extensions:
byte[] FillRandom(this byte[]);
uint[] FillRandom(this uint[]);
ulong[] FillRandom(this ulong[]);
  • Span extensions:
void Split(this Span<uint>, Span<byte>);
void Merge(this Span<byte>, Span<uint>);
void Merge(this Span<byte>, Span<ulong>);
void Merge(this Span<uint>, Span<ulong>);
#if NET7_0_OR_GREATER
void Merge(this Span<uint>, Span<UInt128>);
#endif
void Xor(this Span<byte>, Span<byte>);
void FillRandom(this Span<byte>);
void FillRandom(this Span<uint>);
void FillRandom(this Span<ulong>);

Note that Split and Merge above are endianness agnostic: you will get the same results even on IBM System/390, the only Big Endian platform with .NET support I am aware of.

  • Integers extensions:
void Halve(this ushort, out byte, out byte);
void Halve(this uint, out ushort, out ushort);
void Halve(this ulong, out uint, out uint);
#if NET7_0_OR_GREATER
void Halve(this UInt128, out ulong, out ulong);
#endif
ushort Merge(this byte, byte);
uint Merge(this ushort, ushort);
ulong Merge(this uint, uint);
#if NET7_0_OR_GREATER
UInt128 Merge(this ulong, ulong);
#endif
byte Xor(this byte, byte);

Installation

Install with NuGet Package Manager Console

Install-Package GoeaLabs.Bedrock

Install with .NET CLI

dotnet add package GoeaLabs.Bedrock