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

BassUtils

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

[4.7.0]
Added
  • MsSqlDb simple abstract base class.
[4.6.0]
Added
  • Calculate the process up-time when RuntimeInformation is captured.
[4.4.2]
Fixed
  • Trimmed the READMEs for the 3 BassUtils packages to be just relevant to them.
  • Added NuGet badges.
[4.4.0]
Added
  • Better RuntimeInfo.
  • Add TVP helpers for MS SQL server.
[4.2.0]
Added
  • 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.
[4.1.12]
Added
  • Added IDataReader.ReadOne, HydrateOne and TryHydrateOne methods.
  • Added SqlDataRecord extensions for use with MS-SQL TVPs.
  • Added RuntimeInformation classes.
  • Added BassUtils.NetCore downstream library
Changed
  • ObjectDataReader now inherits from DbDataReader. Previously it just implemented the interface IDataReader, which caused type conversion problems in some advanced scenarios.
[4.0.0]
Changed
  • 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 https://devblogs.microsoft.com/dotnet/introducing-the-new-microsoftdatasqlclient/ 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.
Removed
  • 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.
[3.1.0]
Fixed
  • 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.
Added
  • 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
Fixed
  • In PropertyCopier, only write to properties with a setter.
Added
  • 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.
Changed
  • 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
Fixed
  • Bug fix in ConfigurationLoader regarding multiple named sections.
[2.2.0] - 2015-04-26
Added
  • 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
Added
  • 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
Added
  • PropertyCopier, ThrottledBlockingQueue, ICollectionExtensions.
  • More XML documentation for methods.
Removed
[1.1.1] - 2015-03-23
Added
  • XML documentation for most functions and classes.
[1.1.0] - 2015-03-19
Added
  • 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))
{
    bulkCopy.WriteToServer(sbcReader);
}

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)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on BassUtils:

Package Downloads
BassUtils.NetCore

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,711 1/19/2023
4.6.0 2,052 2/12/2022
4.5.0 381 1/11/2022
4.4.2 355 1/1/2022
4.4.1 315 12/28/2021
4.2.4-alpha-g3e4abfb12d 191 12/17/2021
4.2.2-alpha-g73bc890b96 179 12/16/2021
4.2.1-alpha-gd2c57a210b 192 12/16/2021
4.1.12 5,504 11/24/2021
4.1.0-alpha 196 11/9/2021
4.0.8-pre 187 10/15/2021
4.0.7-pre 236 10/15/2021
4.0.6-pre 196 10/15/2021
4.0.4-pre 225 10/15/2021
4.0.3-pre 214 10/15/2021
4.0.2-pre 247 10/13/2021
4.0.1-pre 294 10/9/2021
4.0.0 368 11/4/2021
4.0.0-pre 260 10/8/2021
3.0.0 7,466 10/29/2015
2.2.1 1,847 4/27/2015
2.2.0 1,262 4/26/2015
2.1.0 1,213 4/18/2015
2.0.0 1,354 3/25/2015
1.1.1 1,195 3/23/2015
1.1.0 1,133 3/21/2015
1.0.0 1,116 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 README.md.