BassUtils 4.6.0

.NET Standard 2.0
dotnet add package BassUtils --version 4.6.0
NuGet\Install-Package BassUtils -Version 4.6.0
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="BassUtils" Version="4.6.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BassUtils --version 4.6.0
#r "nuget: BassUtils, 4.6.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install BassUtils as a Cake Addin
#addin nuget:?package=BassUtils&version=4.6.0

// Install BassUtils as a Cake Tool
#tool nuget:?package=BassUtils&version=4.6.0


NuGet Badge

Low-level utility functions for use in any .Net Standard 2.0 project. Available on NuGet

Also available: BassUtils.NetCore and BassUtils.Oracle

Change History

  • Calculate the process up-time when RuntimeInformation is captured.
  • Trimmed the READMEs for the 3 BassUtils packages to be just relevant to them.
  • Added NuGet badges.
  • Better RuntimeInfo.
  • Add TVP helpers for MS SQL server.
  • AppendLines methods to the StringBuilder extensions and the IndentingStringBuilder.
  • BeginCodeBlock and dispose functionality to IndentingStringBuilder.
  • Async versions of ReadOne, Hydrate and HydrateAll. These are extensions on DbDataReader though, not IDataReader, which doesn't provide async methods.
  • Added IDataReader.ReadOne, HydrateOne and TryHydrateOne methods.
  • Added SqlDataRecord extensions for use with MS-SQL TVPs.
  • Added RuntimeInformation classes.
  • Added BassUtils.NetCore downstream library
  • ObjectDataReader now inherits from DbDataReader. Previously it just implemented the interface IDataReader, which caused type conversion problems in some advanced scenarios.
  • Upgraded to Net Standard 2.0.
  • Some things moved to sub-namespaces 'Data' and 'MsSql'.
  • IniData remains, but the recommendation in its doc-comment has changed to reference ini-parser-netstandard.
  • StreamExtensions.ReadFully has become ReadToEnd.
  • The SqlBulkCopyDataReader class now targets Microsoft.Data.SqlClient, not System.Data.SqlClient. See for background. This means that BassUtils now has a dependency on the Microsoft.Data.SqlClient package.
  • CSV has been changed to 'Csv' for compliance with Microsoft recommended naming standards.
  • GetLeadingNumber and GetTrailingNumber have had their APIs change, and they now work!
  • Regularzie naming in IDataRecordExtensions: GetSingle becomes GetFloat, GetStringOrNull becomes GetNullableString, GetValueOrNull becomes GetNullableValue.
  • Various utilities have been removed due to better alternatives now becoming available in the community or me simply not making any use of them.
  • ArgumentValidators - use Dawn.Guard instead (this library includes it as a dependency).
  • Glob - use Microsoft.Extensions.FileSystemGlobbing
  • Partition and DistinctBy methods - use MoreLinq.
  • ConfigurationLoader, DoubleExtensions, ExpandoExtensions, PredicateBuilder, PropertyCopier, TableAdapterBase, ThrottledBlockingQueue, XmlWriterExtensions have been removed.
  • Removed the Hydate and HydrateAll functions that use reflection to guess a ctor to call. Use the overloads that take a lambda instead, they are more predictable.
  • Make AssemblyExtensions.GetResourceFileName work in ILMerge scenarios by searching for names by partial match if an exact match cannot be found. Still requires unique names.
  • Take the existing AppendCSV functionality and move it to be extensions to the TextWriter class, therefore making it available for use in StreamWriter and StringWriter classes. Also extend the CSVOptions so that the class writes CSV that is more in line with the unofficial CSV specification as described on Wikipedia; in particular see the Standardization section.
  • Add [DebuggerStepThrough] attributes to the ArgumentValidators.
[3.0.0] - 2015-10-29
  • In PropertyCopier, only write to properties with a setter.
  • StringExtensions.TrimAll, RemoveNewLines, ContainsAll.
  • New overload of StringExtensions.SafeFormat that defaults to InvariantCulture.
  • New Glob class (Unix-like file globber)
  • IEnumerableExtensions.DistinctBy.
  • ConfigurationLoader.CanLoad method.
  • IniParser has been refactored into IniData and IniSection classes, and a static Parse method is now the starting point. Tests added, and the ability to parse INI files with duplicate keys and valueless keys added (based on data seen in real-life INI files). This change is the reason for the bump in the version number.
[2.2.1] - 2015-04-27
  • Bug fix in ConfigurationLoader regarding multiple named sections.
[2.2.0] - 2015-04-26
  • Built 4.0 and 4.5 versions of the assembly.
  • Gave ConfigurationLoader the ability to load a section by name, so you can use the same type to load several different (named!) configuration sections.
  • AppDomainExtensions.IsLoaded
  • FileUtils.GetExeDirectory, NormalizeToExeDirectory, NormalizeToDirectory.
  • IEnumerableExtensions.ToHashSet.
[2.1.0] - 2015-04-18
  • StringExtensions.SetChar
  • StringBuilderExtensions.EndsWith, AppendCSV, AppendIfDoesNotEndWith, TrimAppend
  • StringExtensions.AppendCSV, AppendIfDoesNotEndWith, TrimAppend
  • ConfigurationLoader (see documentation in the class or BassUtils.Tests)
[2.0.0] - 2015-03-25
  • PropertyCopier, ThrottledBlockingQueue, ICollectionExtensions.
  • More XML documentation for methods.
[1.1.1] - 2015-03-23
  • XML documentation for most functions and classes.
[1.1.0] - 2015-03-19
  • Conv.StringToBest function.

Highlights (not exhaustive)

AssemblyExtensions Get embedded resources:

string sql = typeof(this).Assembly.GetResourceAsString("Foo.sql");

Comb Generate Guids in a monotonic way for SQL server that will not lead to index fragmentation:

Guid g = Comb.NewGuid();

Conv Convenient conversion functions:

int x = Conv.StringToBest("42");

DirectoryWatcher A wrapper around FileSystemWatcher that will de-duplicate events.

IDataReaderExtensions, IDataRecordExtensions Many extensions to make working with these classes more convenient, including extensions to get columns by name, get columns with defaults if null, and get nullable columns. Also includes convenient Hydrate() methods to create entities.

IndentingStringBuilder A wrapper around StringBuilder that can create indented text. Handy for code generation.

IniData A simple parser for INI files.

ObjectDataReader A very useful class that can wrap any class in an IDataReader, making it possible to bind to it, use SqlBulkCopy etc. Often used in conjunction with the SqlBulkCopyDataReader to perform validation on fields before bulk inserting them:

var orders = new List<Order>();
using (var orderReader = new ObjectDataReader(orders))
using (var bulkCopy = new SqlBulkCopy(conn) { DestinationTableName = "dbo.Orders" })
using (var sbcReader = new SqlBulkCopyDataReader(orderReader, conn, bulkCopy))

SqlBulkCopyExtensions An extension to get the number of rows uploaded:

int numRows = bulkCopy.TotalRowsCopied();

StringExtensions Some handy string extensions:

string key = "Name=Phil".Before("=");
string value = "Name=Phil".After("=");
string s = "Hello".Repeat(3);
string t = "hi".Left(3); // safe.

// Simple CSV-like "listifier". Also on StringBuilder and TextWriter.
string list = "".AppendCsv(number, name, street, town, county, country);
list = "Hello,".AppendIfDoesNotEndWith(",");
list = list.TrimAppend("  world  ");
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on BassUtils:

Package Downloads

Useful extension methods for .Net Core 3.1 and above.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
4.6.0 1,229 2/12/2022
4.5.0 255 1/11/2022
4.4.2 222 1/1/2022
4.4.1 201 12/28/2021
4.2.4-alpha-g3e4abfb12d 101 12/17/2021
4.2.2-alpha-g73bc890b96 91 12/16/2021
4.2.1-alpha-gd2c57a210b 104 12/16/2021
4.1.12 5,370 11/24/2021
4.1.0-alpha 124 11/9/2021
4.0.8-pre 133 10/15/2021
4.0.7-pre 181 10/15/2021
4.0.6-pre 141 10/15/2021
4.0.4-pre 154 10/15/2021
4.0.3-pre 157 10/15/2021
4.0.2-pre 181 10/13/2021
4.0.1-pre 238 10/9/2021
4.0.0 266 11/4/2021
4.0.0-pre 206 10/8/2021
3.0.0 5,340 10/29/2015
2.2.1 1,699 4/27/2015
2.2.0 1,129 4/26/2015
2.1.0 1,082 4/18/2015
2.0.0 1,177 3/25/2015
1.1.1 1,034 3/23/2015
1.1.0 1,010 3/21/2015
1.0.0 996 3/19/2015

2021-11-08 Add BassUtils.NetCore package.
2021-11-04 Convert to .Net Standard 2.0. See