EgonsoftHU.Extensions.Bcl 3.0.1

Prefix Reserved

Requires NuGet 4.1.0 or higher.

dotnet add package EgonsoftHU.Extensions.Bcl --version 3.0.1                
NuGet\Install-Package EgonsoftHU.Extensions.Bcl -Version 3.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="EgonsoftHU.Extensions.Bcl" Version="3.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EgonsoftHU.Extensions.Bcl --version 3.0.1                
#r "nuget: EgonsoftHU.Extensions.Bcl, 3.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.
// Install EgonsoftHU.Extensions.Bcl as a Cake Addin
#addin nuget:?package=EgonsoftHU.Extensions.Bcl&version=3.0.1

// Install EgonsoftHU.Extensions.Bcl as a Cake Tool
#tool nuget:?package=EgonsoftHU.Extensions.Bcl&version=3.0.1                

Egonsoft.HU BCL Extensions

C# extension methods for Base Class Library types.

Summary

  • Extension methods for throwing ArgumentNullException
  • Extension methods for throwing ArgumentException
  • Extension methods for throwing ArgumentOutOfRangeException
  • Extension methods for specific types
  • Extension methods with generic type parameters
  • Predefined (const / readonly) values
  • More information

Extension methods for throwing ArgumentNullException or ArgumentException

  • For generic T type:
    • ThrowIfNull<T>() throws ArgumentNullException
  • For System.String type:
    • ThrowIfNullOrEmpty() throws ArgumentNullException or ArgumentException
    • ThrowIfNullOrWhiteSpace() throws ArgumentNullException or ArgumentException
  • For System.Guid type:
    • ThrowIfEmptyGuid() throws ArgumentException

Extension methods for throwing ArgumentOutOfRangeException

Would you like to use the new static methods in ArgumentOutOfRangeException that were introduced in .NET 8 but your project targets an older framework? In this package they are available as extension methods.

  • For IEquatable<T> type:
    • ThrowIfEqualTo()
    • ThrowIfNotEqualTo()
  • For IComparable<T> type:
    • ThrowIfLessThan()
    • ThrowIfLessThanOrEqualTo()
    • ThrowIfGreaterThan
    • ThrowIfGreaterThanOrEqualTo()
  • For numeric types:
    System.SByte, System.Int16, System.Int32, System.Int64,
    System.Byte, System.UInt16, System.UInt32, System.UInt64,
    System.Half, System.Single, System.Double, System.Decimal
    • ThrowIfZero()
    • ThrowIfNegative()
    • ThrowIfNegativeOrZero()
    • ThrowIfPositive()
    • ThrowIfPositiveOrZero()

Extension methods for specific types

This package contains extension methods for these types:

  • System.Collections.Generic.ICollection<T>
    • AddRange()
  • System.Collections.Generic.IDictionary<TKey, TValue>
    • AsReadOnly()
    • AsSorted()
    • DefaultIfKeyNotFound()
    • GetOrThrow()
  • System.Collections.Generic.IEnumerable<T>
    • IsNullOrEmpty()
    • DetectChanges() - Get new, existing and removed items.
  • System.Collections.Generic.IList<T>
    • AsReadOnly() up to .NET 6 (An extension method with the same signature is part of .NET 7+.)
  • System.DateOnly
    • IsInRange()
  • System.DateTime
    • IsInRange()
    • ToMinutePrecision()
    • ToSecondPrecision()
  • System.DateTimeOffset
    • IsInRange()
    • ToMinutePrecision()
    • ToSecondPrecision()
  • System.Exception
    • GetHttpStatusCode()
    • SetHttpStatusCode()
  • System.IO.Stream
    • ToByteArray()
    • ToByteArrayAsync()
    • TryResetStreamPosition()
  • System.Reflection.Assembly
  • System.Reflection.MemberInfo
  • System.Reflection.ParameterInfo
  • System.String
    • IsNullOrEmpty()
    • IsNullOrWhiteSpace()
    • DefaultIfNullOrEmpty()
    • DefaultIfNullOrWhiteSpace()
    • EnsureTrailingSlash()
    • EnsureNoTrailingSlash()
  • System.Type
    • AsNullableValueType()
    • IsNullableValueType()
  • Numeric types:
    System.SByte, System.Int16, System.Int32, System.Int64,
    System.Byte, System.UInt16, System.UInt32, System.UInt64,
    System.Half, System.Single, System.Double, System.Decimal
    • IsZero()
    • IsNegative()
    • IsNegativeOrZero()
    • IsPositive()
    • IsPositiveOrZero()
    • IsInRange()

Extension methods with generic type parameters

  • IEnumerable-related
    • AsSingleElementSequence()
    • IsIn()
    • IsNotIn()
  • Reflection-related
    • GetPropertyValue()
    • TryPropertyValue()
    • SetPropertyValue()
    • TrySetPropertyValue()
  • value selectors
    • GetStringValueOrNull()
    • GetStringValueOrEmptyString()
    • GetValueOrDefault()
    • GetValue()

Predefined (const / readonly) values

  • Chars
  • DateTimeFormats
  • GenericTypeDefinitions
  • GuidFormats
  • HttpStatusCodes
  • Strings

enum types

  • IntervalBoundsOptions - can be used in the new IsInRange() extension methods.

Other types

  • EnumInfo<TEnum>
    • A wrapper class that provides additional information about an enum type or value.
      • The custom attributes applied to a member.
      • Easy access to the list of the defined members.
      • Easy access to the name or the underlying value of a member.
      • Support for customizing the serialized value through attributes.
      • Implements bitwise / comparison / implicit conversion / equality operators.
  • EncodingProvider
    • UTF8WithoutBOM The UTF-8 encoding without the Unicode byte order mark.
  • StringSyntaxAttribute
    • up to .NET 6 (This attribute is part of .NET 7+.)
  • StructuralEqualityComparer<T>
    • Provides a generic IEqualityComparer<T> instance for using the non-generic System.Collections.StructuralComparisons.StructuralEqualityComparer.
  • TypeHelper
    • GetName<T>() / GetName(Type) methods as a shortcut for Type.FullName ?? Type.Name expression.

More information

Learn more at https://github.com/gcsizmadia/EgonsoftHU.Extensions.Bcl

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 is compatible. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on EgonsoftHU.Extensions.Bcl:

Package Downloads
EgonsoftHU.Extensions.DependencyInjection.Abstractions

Abstractions for dependency injection. Commonly Used Types: EgonsoftHU.Extensions.DependencyInjection.IAssemblyRegistry EgonsoftHU.Extensions.DependencyInjection.DefaultAssemblyRegistry

EgonsoftHU.Extensions.Logging.Serilog

Serilog.ILogger extensions: - Enrich log events with the name of the source member (method, property, etc.) in which the log event occurs. - Enrich log events with multiple properties at once using PropertyBagEnricher. - Populate Exception.Data dictionary with the log event properties.

EgonsoftHU.Text.Json

System.Text.Json extensions. Supports any attribute for enum member serialization. Provides option for using your own custom serializer implementation for enum members. Built-in attribute support: System.Text.Json.Serialization.JsonStringEnumMemberNameAttribute (>= 9.0.0) System.Runtime.Serialization.EnumMemberAttribute System.ComponentModel.DescriptionAttribute System.ComponentModel.DisplayNameAttribute System.ComponentModel.DataAnnotations.DisplayAttribute Commonly Used Types: EgonsoftHU.Text.Json.Serialization.JsonStringEnumConverter EgonsoftHU.Text.Json.Serialization.Converters.JsonEnumValueSerializer EgonsoftHU.Text.Json.JsonSerializerOptionsProvider

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.1 211 10/14/2024
3.0.0 118 9/13/2024
2.1.0 629 8/27/2023
2.0.0 6,354 6/21/2022
1.0.3 1,059 5/4/2022
1.0.2 4,779 3/13/2022
1.0.1 859 3/2/2022
1.0.0 835 2/4/2022