BassUtils 4.7.0

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

// Install BassUtils as a Cake Tool
#tool nuget:?package=BassUtils&version=4.7.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

  • MsSqlDb simple abstract base class.
  • 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 Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  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)
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.7.0 1,619 1/19/2023
4.6.0 2,047 2/12/2022
4.5.0 375 1/11/2022
4.4.2 350 1/1/2022
4.4.1 310 12/28/2021
4.2.4-alpha-g3e4abfb12d 188 12/17/2021
4.2.2-alpha-g73bc890b96 176 12/16/2021
4.2.1-alpha-gd2c57a210b 188 12/16/2021
4.1.12 5,499 11/24/2021
4.1.0-alpha 193 11/9/2021
4.0.8-pre 183 10/15/2021
4.0.7-pre 232 10/15/2021
4.0.6-pre 193 10/15/2021
4.0.4-pre 221 10/15/2021
4.0.3-pre 211 10/15/2021
4.0.2-pre 243 10/13/2021
4.0.1-pre 291 10/9/2021
4.0.0 364 11/4/2021
4.0.0-pre 256 10/8/2021
3.0.0 7,346 10/29/2015
2.2.1 1,845 4/27/2015
2.2.0 1,259 4/26/2015
2.1.0 1,210 4/18/2015
2.0.0 1,353 3/25/2015
1.1.1 1,192 3/23/2015
1.1.0 1,131 3/21/2015
1.0.0 1,114 3/19/2015

2023-01-19 New version 4.7.0. Add MsSqlDb base class.
2021-11-08 Add BassUtils.NetCore package.
2021-11-04 Convert to .Net Standard 2.0. See