DX.Utils
26.1.3.38
See the version list below for details.
dotnet add package DX.Utils --version 26.1.3.38
NuGet\Install-Package DX.Utils -Version 26.1.3.38
<PackageReference Include="DX.Utils" Version="26.1.3.38" />
<PackageVersion Include="DX.Utils" Version="26.1.3.38" />
<PackageReference Include="DX.Utils" />
paket add DX.Utils --version 26.1.3.38
#r "nuget: DX.Utils, 26.1.3.38"
#:package DX.Utils@26.1.3.38
#addin nuget:?package=DX.Utils&version=26.1.3.38
#tool nuget:?package=DX.Utils&version=26.1.3.38
DX.Utils
General-purpose C# helper classes and extension methods used throughout the DXWeb package family. No DevExpress dependency — this package is plain .NET and can be used standalone in any project.
Target frameworks: net462, net8.0, net9.0, net10.0
Install
dotnet add package DX.Utils
What's in the box
Attributes.cs — reflection over attributes
public static class Attributes
{
public static IEnumerable<Type> GetTypesWith<TAttribute>(bool inherit = false) where TAttribute : Attribute;
public static TResult? GetAttributeData<TAttribute, TResult>(MemberInfo member, Func<TAttribute, TResult> selector) where TAttribute : Attribute;
}
GetTypesWith<TAttribute>() scans loaded assemblies for every type decorated with TAttribute. GetAttributeData pulls a single value off a member's attribute without you having to null-check GetCustomAttribute yourself.
Also included: RequiredIfAttribute, a ValidationAttribute that makes a property required only when another named property equals a given value (compiled only for non-.NET-Framework TFMs).
Bits.cs — bit-flag helpers
public static class Bits
{
public static int BitSet(int value, int bit);
public static int BitClear(int value, int bit);
public static int BitToggle(int value, int bit);
public static bool BitHas(int value, int bit);
}
Plus the same four operations as extension methods on int (BitsExtensions), so myFlags.BitHas(4) reads naturally at call sites. Used internally by DX.Data.Xpo.Identity for its legacy loading-flags scheme.
Collection.cs — typed collection base classes
CollectionItem, BaseCollection, and generic Collection<TItemClass> — an old-style strongly-typed collection base (pre-List<T>/ObservableCollection<T> era) kept for backward compatibility with consumers that still derive from it.
Conversion.cs — safe parsing & config helpers
public static class Utils
{
public static T Iif<T>(bool condition, T trueValue, T falseValue);
}
public static class ListExtensions
{
public static void RemoveAll<T>(this IList<T> list, Action<T> beforeRemove);
}
public static class Conversion
{
public static int ParseInt(object value, int defaultValue = 0);
public static double ParseDouble(object value, double defaultValue = 0);
public static decimal ParseDecimal(object value, decimal defaultValue = 0);
public static bool ParseBool(object value, bool defaultValue = false);
public static TEnum ParseEnum<TEnum>(object value, TEnum defaultValue) where TEnum : struct;
public static string GetConfigOption(string key, string defaultValue = "");
public static T MinValue<T>(T a, T b);
public static T MaxValue<T>(T a, T b);
}
All the Parse* methods swallow format/overflow exceptions and fall back to defaultValue — handy for reading loosely-typed data (query strings, DataRow cells, config values) without wrapping every call in a try/catch.
DateTimeExtensions.cs
public static DateTime DateMin(this DateTime a, DateTime b);
public static DateTime DateMax(this DateTime a, DateTime b);
EnumExtensions.cs — DisplayAttribute-aware enum labels
public static string GetDisplay(this Enum value);
public static IEnumerable<(TEnumType Value, string Display)> GetDisplayValues<TEnumType>() where TEnumType : struct, Enum;
Reads [Display(Name = "...", ResourceType = ...)] off enum members (falling back to the raw member name), so you can bind enums to dropdowns/grids with human-readable, localizable labels in one call.
ExceptionExtensions.cs
public static Exception GetInnerException(this Exception ex);
Walks InnerException all the way down and returns the innermost exception — useful when surfacing the real error message from a wrapped AggregateException/TargetInvocationException.
GeoHaversine.cs — great-circle distance
public enum GeoScale { KM, Mtr, Mile }
public static double Haversine(double lat1, double lon1, double lat2, double lon2, GeoScale scale = GeoScale.KM);
public static double Distance(double lat1, double lon1, double lat2, double lon2);
public static double DistanceKM(double lat1, double lon1, double lat2, double lon2);
public static double DistanceMtr(double lat1, double lon1, double lat2, double lon2);
public static double DistanceMile(double lat1, double lon1, double lat2, double lon2);
Log.cs — minimal thread-static logger
public static class Log
{
public static void Exception(Exception ex);
public static void Write(string message);
public static string GetLog();
public static void ClearLog();
}
Backed by UtilsConfig.LoggerType (read from the DXWeb/Utils config section) so the logging target can be swapped without code changes.
PropertyExtensions.cs — reflection-based object utilities
public static bool HasProperty(this object obj, string name);
public static T GetPropertyValue<T>(this object obj, string name);
public static void SetPropertyValue(this object obj, string name, object value);
public static bool IsCollectionProperty(this PropertyInfo property);
public static TDestination Assign<TSource, TDestination>(this TDestination destination, TSource source);
public static IDictionary<string, object> AsDictionary(this object source);
public static string AppendQueryParameters(this string url, object parameters);
public static string AsQueryParameters(this object source);
AppendQueryParameters/AsQueryParameters build a query string from an object's public properties via reflection — decorate a property with [AppendQueryIgnoreAttribute] to skip it, or [AppendQueryFormatAttribute("...")] to control how it's rendered. Assign is a shallow reflection-based property copier between two (possibly unrelated) types, used internally by several XPDataStore/EFDataStore implementations to refresh a model after a commit.
RegExLibrary.cs — precompiled regexes
Static, precompiled Regex fields: EmailParser, QueryStringParser, UrlParser, SEOSafe, SEOReplaceSpaces, and a handful of legacy ASP.NET URL-rewrite parsers.
Strings.cs — string helpers
public static class Strings
{
public static string StripHTMLTags(string html);
public static string Join(string separator, params string[] values); // skips null/empty entries
public static string CopyMaxLength(string value, int maxLength);
public static string InsureHtmlParagraph(string html);
public static string HtmlColor(Color color);
public static string FormatFileSize(long bytes);
public static string RemoveDiacritics(string value);
public static string MakeSEOSafe(string value);
public static string MakeFileNameSEOSafe(string value);
}
UtilsConfig.cs
public sealed class UtilsConfig
{
public static UtilsConfig Current { get; }
public string LoggerType { get; }
}
Singleton that reads the DXWeb/Utils custom config section (app/web.config on Framework, or the matching config provider on .NET) to configure Log's backing logger type.
Notes
Urls.csis compiled only under#if INC_URLSand is not part of the default build (legacy ASP.NET WebForms-era helpers).- This package has no DevExpress dependency and is version-bumped alongside the rest of the DXWeb release wave purely for consistency — you can safely pin it independently.
See the root README for the full package list and DevExpress version alignment notes.
| 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 is compatible. 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 is compatible. 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. |
| .NET Framework | net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
.NETFramework 4.6.2
- System.ComponentModel.Annotations (>= 5.0.0)
-
net10.0
- System.ComponentModel.Annotations (>= 5.0.0)
- System.Configuration.ConfigurationManager (>= 8.0.0)
-
net8.0
- System.Configuration.ConfigurationManager (>= 8.0.0)
-
net9.0
- System.Configuration.ConfigurationManager (>= 8.0.0)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on DX.Utils:
| Package | Downloads |
|---|---|
|
DX.Data.Xpo
Several XPO Related Helper classes and abstract DX.Data.IDataStore implementation for use with XPO with FluentValidation and no Mapping logic |
|
|
DX.Data.Xpo.Identity
XPO Based abstract storage provider for ASP.NET Identity |
|
|
DX.Data.Xpo.Mvc
Several extension classes and methods on DevExpress MVC Controls, XPO and XPDataStore implementations. This package needs an active DevExpress ASP.NET license |
|
|
DX.Data.EF
Abstract DX.Data.IDataStore implementation for use with EF with FluentValidation and no Mapping logic |
|
|
DX.Data.Xpo.Interfaces
Package with Interface for DX.Data.XPO.Identity ASP.NET Identity |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 26.1.3.42 | 181 | 11/5/2026 |
| 26.1.3.41 | 254 | 11/4/2026 |
| 26.1.3.40 | 594 | 8/5/2026 |
| 26.1.3.39 | 163 | 8/3/2026 |
| 26.1.3.38 | 370 | 7/31/2026 |
| 26.1.3.37 | 378 | 7/14/2026 |
| 25.2.3.35 | 371 | 4/7/2026 |
| 24.2.3.34 | 1,116 | 12/13/2024 |
| 23.2.3.33 | 985 | 9/17/2024 |
| 23.2.3.32 | 400 | 9/17/2024 |
| 23.2.3.31 | 1,821 | 1/11/2024 |
| 20.1.8.26 | 535 | 12/19/2023 |
| 20.1.8.25 | 474 | 12/14/2023 |
| 20.1.8.24 | 3,139 | 1/4/2023 |
| 20.1.8.22 | 1,236 | 11/1/2022 |
| 20.1.8.20 | 1,510 | 8/3/2022 |
| 20.1.8.19 | 1,623 | 6/16/2022 |
| 20.1.7.19 | 2,462 | 12/20/2021 |
| 20.1.7.18 | 3,092 | 3/12/2021 |
| 20.1.7.17 | 632 | 3/12/2021 |
26.1.3.38: Added a README.md with technical documentation, now embedded in the package via PackageReadmeFile.
26.1.3.37: Fixed IDE1005, IDE0059 and CA1304/CA1307/CA1310/CA1805-class analyzer warnings in Conversion.cs
(simplified conditional delegate invocation, removed dead re-assignments in catch blocks, and made
ParseBool's string comparison culture- and comparison-explicit). No behavior change.
23.2.3.34: .NETv9 support
23.2.3.31: Data.DataStore plus Validator and Mapper have been moved and simplified into package DX.Data
BREAKING CHANGES:
Data classes moved to DX.Data package
DX.Data package refactored to use FluentValidation with simplyfied validation logic
20.1.8.25: Upgrade to .NET 8
20.1.8.24: static class renamed in Strings.cs
20.1.8.22: IsCollectionProperty extension method added to fix bug in DX.Data.Xpo
20.1.8.21: Upgrade from .NET Framework to 4.6.1 to 4.6.2
20.1.8.20: Fix
20.1.8.19: Small fix
20.1.7.19: .NET 6.0 upgrade
20.1.7.17: IDataStoreModel<TKey> not needed anymore on Models and DBModels. No ID property needed.
20.1.7.16: Validation results include eventType (inserting, Inserted etc), Exception helper class for results, smaller fixes
20.1.3.15: Upgrade to DX v20.1.3
20.1.2.14-pre-20064: Upgrade to DX v20.1.2-pre-20064 and .NET preview 5
1.0.0.14: BREAKING CHANGE: Signature-change on IDataValidator<..>.Deleting(..):
Was: Deleting(TKey id, object arg, IDataValidationResults<TKey> validationResults);
Is: Deleting(TKey id, IDataValidationResults<TKey> validationResults, params object[] args);
1.0.0.13: ListExtensions added
1.0.0.12: dotnet standard 2.1 for dotnet core v3.1 support
1.0.0.10: Small fixes and implementation of DataMapper and DataValidator
1.0.0.8: Small refactorings to improve speed and support for Pageable (XP)DataStore
1.0.0.7: Abstract Generic DTO DataStore and Validator classes added
1.0.0.6: Changed .NET Framework to v4.6.1
1.0.0.5: Initial dual mode package for .NET Framework and .NET Standard 2.0
Some features don't work yet on .NET Standard 2.0