Skip to content

Part of dotnet.devfast project, contains generic extensions.

License

Notifications You must be signed in to change notification settings

samaysar/dotnet.devfast.extensions

Repository files navigation

Part of dotnet.devfast project.

DevFast.Net.Extensions Build status codecov NuGet

Developer Documentation, Release Notes

This project contains well-tested, self-explained & easy to use extension methods to achieve optimized runtime performance with improved readability of the code.

Examples

String Parsing

String parsing becomes as easy as stringValue.TryTo(out <T> ...) (where T can be bool, Guid, int, double, decimal, DateOnly, DateTime, TimeOnly etc...):

  • "123".TryTo(out int parsedInt) should return true with parsedInt as 123.

Similar ".TryTo" also exists on ReadOnlySpan<char> and ReadOnlySpan<byte>

Avoid NullReferenceException on String

  • possibleNullString?.Trim() ?? string.Empty Becomes possibleNullString.TrimSafeOrEmpty()
  • possibleNullString?.Trim().ToUpper() ?? string.Empty Becomes possibleNullString.TrimSafeAndUpper() (same for Upper and more...)

Working on Byte Arrays (byte[])

  • myByteArray.LiftNCopySafe(...) moves bytes with-in Arrays
  • myByteArray.DoubleByteCapacity() returns new array with initial bytes but twice the capacity
  • myByteArray.CopyToSafe(...) copies bytes to targeted array

IEnumerable & IAsyncEnumerable with CancellationToken All the Way

  • ForEach, ForEachAsync, ToBlockingEnumerable with CancellationToken
  • CancellationToken support for SelectAsync, SkipAsync, TakeAsync, WhereAsync, CountAsync, ToChunksAsync etc.

About

Part of dotnet.devfast project, contains generic extensions.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages