BassUtils 4.2.4-alpha-g3e4abfb12d

.NET Standard 2.0
This is a prerelease version of BassUtils.
There is a newer version of this package available.
See the version list below for details.
Install-Package BassUtils -Version 4.2.4-alpha-g3e4abfb12d
dotnet add package BassUtils --version 4.2.4-alpha-g3e4abfb12d
<PackageReference Include="BassUtils" Version="4.2.4-alpha-g3e4abfb12d" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BassUtils --version 4.2.4-alpha-g3e4abfb12d
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: BassUtils, 4.2.4-alpha-g3e4abfb12d"
#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.2.4-alpha-g3e4abfb12d&prerelease

// Install BassUtils as a Cake Tool
#tool nuget:?package=BassUtils&version=4.2.4-alpha-g3e4abfb12d&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

BassUtils

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

BassUtils.NetCore

Low-level utility functions for use in any .Net Core 3.1 and later project. Available on NuGet

BassUtils.Oracle

Low-level utility functions for Oracle.ManagedDataAccess.Core. Available on NuGet

Change History

[4.2.0]
  • Added AppendLines methods to the StringBuilder extensions and the IndentingStringBuilder.
  • Added BeginCodeBlock and dispose functionality to IndentingStringBuilder.
  • Added 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 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
.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
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.6.0 171 2/12/2022
4.5.0 134 1/11/2022
4.4.2 96 1/1/2022
4.4.1 86 12/28/2021
4.2.4-alpha-g3e4abfb12d 58 12/17/2021
4.2.2-alpha-g73bc890b96 59 12/16/2021
4.2.1-alpha-gd2c57a210b 74 12/16/2021
4.1.12 5,260 11/24/2021
4.1.0-alpha 95 11/9/2021
4.0.8-pre 104 10/15/2021
4.0.7-pre 150 10/15/2021
4.0.6-pre 112 10/15/2021
4.0.4-pre 124 10/15/2021
4.0.3-pre 131 10/15/2021
4.0.2-pre 153 10/13/2021
4.0.1-pre 209 10/9/2021
4.0.0 195 11/4/2021
4.0.0-pre 179 10/8/2021
3.0.0 4,277 10/29/2015
2.2.1 1,573 4/27/2015
2.2.0 999 4/26/2015
2.1.0 956 4/18/2015
2.0.0 1,026 3/25/2015
1.1.1 903 3/23/2015
1.1.0 893 3/21/2015
1.0.0 870 3/19/2015

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