JJ.Framework.Common 0.250.2093

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package JJ.Framework.Common --version 0.250.2093
                    
NuGet\Install-Package JJ.Framework.Common -Version 0.250.2093
                    
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="JJ.Framework.Common" Version="0.250.2093" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="JJ.Framework.Common" Version="0.250.2093" />
                    
Directory.Packages.props
<PackageReference Include="JJ.Framework.Common" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add JJ.Framework.Common --version 0.250.2093
                    
#r "nuget: JJ.Framework.Common, 0.250.2093"
                    
#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.
#:package JJ.Framework.Common@0.250.2093
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=JJ.Framework.Common&version=0.250.2093
                    
Install as a Cake Addin
#tool nuget:?package=JJ.Framework.Common&version=0.250.2093
                    
Install as a Cake Tool

JJ.Framework.Common

A mixed bag of general-purpose utilities with minimal dependencies. Later versions of this library split functionality into focused packages like JJ.Framework.Text, JJ.Framework.Collections, and JJ.Framework.Exceptions. This "prequel" version, contains a little bit of everything: a version released in aid of releasing older legacy apps, still holding value.

Contents

String Extensions

  • Left / Right
    • Return the left or right part of a string:
    • "12345".Left(2) = "12"
    • "12345".Right(2) = "45"
    • (Throws an exception if the string is shorter than the requested length.)
  • FromTill
    • Takes the middle of a string by specifying the zero-based start index and the end index:
    • "12345".FromTill(2, 3) = "34"
    • (Throws an exception if the indexes are out of range.)
  • CutLeft / CutRight
    • Trim off at most one occurrence of a value from the given string:
    • "BlaLala".CutLeft("Bla") = "Lala"
    • "12345".CutRight(2) = "123"
  • CutLeftUntil / CutRightUntil
    • Cuts off part of a string until the specified delimiter and returns what remains including the delimiter itself:
    • "Path/to/file.txt".CutRightUntil("/") = "Path/to/"
    • "Hello world!".CutLeftUntil("world") = "world!"
  • RemoveExcessiveWhiteSpace
    • Trims and replaces sequences of two or more white space characters by a single space:
    • " This is a test. ".RemoveExcessiveWhiteSpace() = "This is a test."
  • Replace
    • Variation on String.Replace with the ability to ignore case:
    • "HelloWORLD".Replace("world", "Universe", ignoreCase: true) = "HelloUniverse"
  • StartWithCap
    • Turns the first character into a capital letter:
    • "test".StartWithCap() = "Test"
  • StartWithLowerCase
    • Turns the first character into a lower-case letter.
    • "TEST".StartWithLowerCase() = "tEST"
  • Split
    • A variant one that takes params for split characters + overloads mostly missing before .NET 5:
    • "apple-banana|cherry".Split("-", "|") =
      [ "apple", "banana", "cherry" ]
  • SplitWithQuotation
    • Allows you to parse CSV-like lines including quotation for the ability to include the separator character and quote characters in the values themselves:
    • "apple|~banana|split~|cherry".SplitWithQuotation("|", '~') =
      [ "apple", "banana|split", "cherry" ]

Collection Extensions

  • TrimAll
    • Trims all the strings in the collection.
  • Distinct
    • Variation that takes a key selector that determines what makes an item unique, e.g.
    • myItems.Distinct(x => x.LastName);
    • For multi-part as keys, use:
    • myItems.Distinct(x => new { x.FirstName, x.LastName });
  • Except
    • Variations with:
    • A single item, e.g. myCollection.Except(myItem);
    • The choice to keep duplicates. (The original Except method from .NET automatically does a distinct, which is something you do not always want.)
  • Union
    • Variations with:
    • A single item, e.g. myCollection.Union(myItem);
    • Starts with a single item and then adds a collection to it e.g. myItem.Union(myCollection);
  • ForEach
    • Not all collection types have the ForEach method. Here you have an overload for IEnumerable<T> so you can use it for more collection types.
  • Add
    • Add multiple items to a collection by means of a comma separated argument list, e.g. myCollection.Add(1, 5, 12);
  • AddRange
    • AddRange is a member of List<T>. Here is a variation for IList<T> to support more collection types.
  • AsEnumerable
    • Converts a single item to a enumerable. Example: IEnumerable<int> myInts = 3.AsEnumerable();

Recursive Collection Extensions

LINQ methods already allow you to process a whole collection of items in one blow. Process a whole tree of items in one blow? For many cases these Recursive Collection Extensions offer a one-line solution.

This line of code:

var allItems = myRootItems.UnionRecursive(x => x.Children);

Gives you a list of all the nodes in a tree structure like the following:

var root = new Item
{
    Children = new[]
    {
        new Item()
        new Item
        {
            Children = new[]
            {
                new Item()
            }
        },
        new Item
        {
            Children = new[]
            {
                new Item(),
                new Item(),
            }
        },
    }
};

There is also a SelectRecursive method:

var allItemsExceptRoots = myRootItems.SelectRecursive(x => x.Children);

The difference with UnionRecursive is that SelectRecursive does not include the roots in the result collection.

KeyValuePairHelper

Converts a single array to KeyValuePair or Dictionary, where the 1st item is a name, the 2nd a value, the 3rd a name, the 4th a value, etc. This can be useful to be able to specify name/value pairs as params (variable amount of arguments). For instance:

void MyMethod(params object[] namesAndValues)
{
    var dictionary = KeyValuePairHelper.ConvertNamesAndValuesListToDictionary(namesAndValues);
    ...
}

Calling MyMethod looks like this:

MyMethod("Name1", 3, "Name2", 5, "Name3", 6);

Exception Types

Offers a minimal amount of 2 exception types with subtle differences:

  • InvalidValueException
    • With messages like: Invalid CustomerType value: 'Undefined'.
  • ValueNotSupportedException
    • With messages like: CustomerType value 'Subscriber' is not supported.

Misc Helpers

  • ConfigurationHelper
    • Legacy helper for using configuration settings on platforms where System.Configuration was not available.
  • CultureHelper
    • To set thread culture with a single code line.
  • EmbeddedResourceHelper
    • Make it a little easier to get embedded resource Streams, bytes and strings.
  • KeyHelper
    • Utility to produce keys for use in Dictionaries by concatinating values with a GUID separator in between.
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 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 was computed.  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 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 is compatible. 
.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 (5)

Showing the top 5 NuGet packages that depend on JJ.Framework.Common:

Package Downloads
JJ.Framework.Reflection

Expressions like "myParam.MyList[i].MyProperty" can be converted to text or their value retrieved or info like { "MyMethod", Parameters = { "myParameter", int, 3 } } Accessor IsIndexer IsNullableType IsProperty IsReferenceType IsStatic IsSimpleType IsDefault GetBaseClasses GetImplementations GetItemType GetPropertyOrException GetUnderlyingNullableTypeFast TypesFromObjects. ReflectionCache with fast GetProperties GetFields GetConstructor GetTypeByShortName. Overloads for PropertInfo.GetValue IsAssignableFrom IsAssignableTo CreateInstance.

JJ.Framework.Conversion

Makes it easier to convert simple types.

JJ.Framework.Collections

LINQ overloads. SelectRecursive SelectAncestors Add Remove AddRange Concat CrossJoin Distinct DistinctMany Except FirstWithClearException SingleOrDefaultWithClearException SingleWithClearException ForEach IndexOf TryGetIndexOf MinOrDefault MaxOrDefault PeekOrDefault PopOrDefault Product RemoveFirst Repeat ToHashSet ToNonUniqueDictionary TrimAll TryRemoveFirst Union Zip item.AsArray item.AsList item.AsEnumerable. Also a RedBlackTree and KeyValuePairHelper ConvertNamesAndValuesListToKeyValuePairs and ConvertNamesAndValuesListToDictionary.

JJ.Framework.Mathematics

Interpolator Smooth Bezier Cubic Hermite TextPlotter NumberBases ToBase FromBase ToHex FromHex ToLetterSequence FromLetterSequence Randomizer GetRandomItem GetInt32 GetDouble GetSingle IsInRectangle GetCenter AbsoluteDistance IsPowerOf2 LogRatio RoundToSignificantDigits RoundWithStep ScaleLinearly SpeadItems SpreadIntegers SpreadDoubles. Integer variation of Pow and Log.

JJ.Framework.Configuration

Allows you to work with complex configuration structures in your app.config or web.config files. Doing it the classic way with System.Configuration is difficult and error prone. JJ.Framework.Configuration makes it super easy.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.5.6877.41321 3,330 10/31/2018
0.250.3184 342 6/24/2025
0.250.3081 344 6/14/2025
0.250.3080 421 6/14/2025
0.250.2324 313 4/27/2025
0.250.2323 318 4/27/2025
0.250.2322 314 4/27/2025
0.250.2313 341 4/27/2025
0.250.2207 410 4/22/2025
0.250.2204 298 4/22/2025
0.250.2175 281 4/21/2025
0.250.2174 249 4/21/2025
0.250.2171 389 4/21/2025
0.250.2122 263 4/19/2025
0.250.2120 267 4/19/2025
0.250.2115 290 4/19/2025
0.250.2093 323 4/17/2025
Loading failed