JJ.Framework.Common.Legacy
0.250.4205
Prefix Reserved
dotnet add package JJ.Framework.Common.Legacy --version 0.250.4205
NuGet\Install-Package JJ.Framework.Common.Legacy -Version 0.250.4205
<PackageReference Include="JJ.Framework.Common.Legacy" Version="0.250.4205" />
<PackageVersion Include="JJ.Framework.Common.Legacy" Version="0.250.4205" />
<PackageReference Include="JJ.Framework.Common.Legacy" />
paket add JJ.Framework.Common.Legacy --version 0.250.4205
#r "nuget: JJ.Framework.Common.Legacy, 0.250.4205"
#:package JJ.Framework.Common.Legacy@0.250.4205
#addin nuget:?package=JJ.Framework.Common.Legacy&version=0.250.4205
#tool nuget:?package=JJ.Framework.Common.Legacy&version=0.250.4205
JJ.Framework.Common.Legacy
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. Now targets .NET 9
and .NET Standard
for wide compatibility and tested with 💯%
code coverage.
Contents
- String Extensions
- Collection Extensions
- Recursive Collection Extensions
- KeyValuePairHelper
- Exception Types
- Misc Helpers
String Extensions
Left
/Right
- Return the left or right part of a string:
"12345".Left(2)
="12"
"12345".Right(2)
="45"
- (Throws exception if string shorter than requested length.)
FromTill
- Take the middle of a string by start/end index (zero‑based, inclusive)
"12345".FromTill(2, 3)
="34"
- (Throws exception if indexes out of range.)
CutLeft
/CutRight
- Trim at most one occurrence of a value from the given string:
"BlaLala".CutLeft("Bla")
="Lala"
"12345".CutRight(2)
="123"
CutLeftUntil
/CutRightUntil
- Remove text until the delimiter, keeping the delimiter:
"Path/to/file.txt".CutRightUntil("/")
="Path/to/"
"Hello world!".CutLeftUntil("world")
="world!"
StartWithCap
/StartWithLowerCase
- Change just the first character's case:
"test".StartWithCap()
="Test"
"TEST".StartWithLowerCase()
="tEST"
Split
- Adds overloads missing until .NET 5 and a
params
variant for delimiters: "apple-banana|cherry".Split("-", "|")
=[ "apple", "banana", "cherry" ]
- Adds overloads missing until .NET 5 and a
SplitWithQuotation
- Parse CSV-like lines honoring quotes to allow use of separator and quote characters within the values themselves:
"apple|~banana|split~|cherry".SplitWithQuotation("|", '~')
=[ "apple", "banana|split", "cherry" ]
RemoveExcessiveWhiteSpace
- Trim and replace sequences of two or more white space characters by a single space:
" This is a test. ".RemoveExcessiveWhiteSpace()
="This is a test."
Replace
String.Replace
variant with optional case-insensitive match:"HelloWORLD".Replace("world", "Universe",
ignoreCase: true
)
="HelloUniverse"
Collection Extensions
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);
Add
- Add multiple items to a collection by means of a comma separated argument list, e.g.
myCollection.Add(1, 5, 12);
- Add multiple items to a collection by means of a comma separated argument list, e.g.
AddRange
AddRange
is a member ofList
<T
>. Here is a variation forIList
<T
> to support more collection types.
ForEach
- Not all collection types have the
ForEach
method. Here you have an overload forIEnumerable
<T
> so you can use it for more collection types.
- Not all collection types have the
AsEnumerable
- Converts a single item to a enumerable, so you can for instance use it with
LINQ
: IEnumerable<int> myInts = 3.AsEnumerable();
- Converts a single item to a enumerable, so you can for instance use it with
TrimAll
- Trims all the strings in the collection:
string[] trimmedTexts = myTexts.TrimAll()
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
2 exception types with subtle differences:
InvalidValueException
- With messages like:
Invalid CustomerType value: 'Undefined'.
when you throw:
throw new InvalidValueException(CustomerType.Undefined)
- With messages like:
ValueNotSupportedException
- With messages like:
CustomerType value: 'Subscriber' is not supported.
when you throw:
throw new ValueNotSupportedException(CustomerType.Subscriber)
- With messages like:
Misc Helpers
EmbeddedResourceHelper
- Make it a little easier to get embedded resource
Streams
,bytes
andstrings
.
- Make it a little easier to get embedded resource
CultureHelper
- To set thread culture with a single code line.
ConfigurationHelper
- Legacy helper for using configuration settings on platforms where
System.Configuration
was not available.
- Legacy helper for using configuration settings on platforms where
KeyHelper
- Utility to produce keys for use in
Dictionaries
by concatenating values with aGUID
separator in between.
- Utility to produce keys for use in
💬 Feedback
Found an issue? Let me know.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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 is compatible. 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. |
-
.NETStandard 2.0
- JJ.Framework.PlatformCompatibility.Legacy (>= 0.250.4205)
-
.NETStandard 2.1
- JJ.Framework.PlatformCompatibility.Legacy (>= 0.250.4205)
-
net6.0
- JJ.Framework.PlatformCompatibility.Legacy (>= 0.250.4205)
-
net7.0
- JJ.Framework.PlatformCompatibility.Legacy (>= 0.250.4205)
-
net8.0
- JJ.Framework.PlatformCompatibility.Legacy (>= 0.250.4205)
-
net9.0
- JJ.Framework.PlatformCompatibility.Legacy (>= 0.250.4205)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on JJ.Framework.Common.Legacy:
Package | Downloads |
---|---|
JJ.Framework.Common.Core
Lightweight .NET utilities for name/expression introspection, flag operations and environment variables. |
|
JJ.Framework.Existence.Core
Check for emptiness and code fallbacks more easily. Simple commands like Has(text), Coalesce(a,b,c) and list.Where(FilledIn) to replace garbage like !Equals(x, default(T?)) && !Equals(x, default(T)) and string.IsNullOrWhiteSpace(text), so you can code like you mean it! |
|
JJ.Framework.Reflection.Legacy
For expressions and reflection. Turn lambdas into text: "myParam.MyList[i].MyProperty". Extract structured method call data: { "MyMethod", Parameters = { "myParameter", int, 3 } }. Find types and implementations for plug-ins. Access private members with Accessors. Use ReflectionCache for fast access to properties, fields, methods and indexers. Includes helpers like IsIndexer, IsStatic and more! |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
0.250.4205 | 14 | 7/21/2025 |
0.250.3304 | 117 | 7/5/2025 |
0.250.3301 | 143 | 7/5/2025 |
0.250.3296 | 184 | 7/3/2025 |
0.250.3283 | 203 | 7/3/2025 |
0.250.3272 | 233 | 7/2/2025 |
0.250.3271 | 165 | 7/2/2025 |
0.250.3270 | 141 | 7/2/2025 |
0.250.3268 | 133 | 7/2/2025 |