No depndencies, providing compatible implementations for .NET Framework similar to some of .NET Core functions.
You can use it to get the following support:
- Provide compatibility implementation of some new features of .NET Core for .NET Framework.
- Common data structures and some code patterns.
These frameworks are supported:
Frameworks | Versions |
---|---|
.NET | |
.NET Standard | |
.NET Framework |
-
.NET CLI
dotnet add package NStandard
-
Add new class JsonImplConverter to use instance types when serializing interfaces to Json.
-
Add string extension methods for removing head or tail substrings from a string.
- StringExtensions.TrimStart(this string @this, string trimString)
- StringExtensions.TrimStart(this string @this, params string[] trimStrings)
- StringExtensions.TrimEnd(this string @this, string trimString)
- StringExtensions.TrimEnd(this string @this, params string[] trimStrings)
-
Provide more options for Sliding.
- Add a class Snowflake128 to generate Snowflake ID128 or Guid.
- Add a class Snowflake to generate Snowflake ID.
- Add a method PadSlide to create a Sliding with padding.
- Add a method group to compares two floats/doubles if they are similar.
- Method group: MathEx.Approximately.
- Similar to UnityEngine.Mathf.Approximately, but the tolerance can be specified.
- False:
2.4 + 2.4 - 1.2 == 3.6
- True:
MathEx.Approximately(2.4 + 2.4 - 1.2, 3.6)
- Provide singleton interface: ISingleton<T>.
- IUnitValue is obsolete, use IMeasurable instead.
- StorageValue is obsolete, use StorageCapacity instead.
- New measure classes supported: Measures.Length, Measures.Weight.
- Add a new structure: MinMaxPair.
- AsIndexValuePairs has been renamed to Pairs.
- Add a new method Clone to ValueDiff, which is used to create a shallow copy of the original object.
- Add new class ValueDiff, describing the value of the state difference.
- Add MathEx.Ceiling for calculations that round numbers up to the nearest multiple of significance.
- Add MathEx.Floor for calculations that round numbers down to the nearest multiple of significance.
- MathEx.Permutation is obsolete, use MathEx.Permut instead.
- MathEx.Combination is obsolete, use MathEx.Combin instead.
- Adjusted JsonXmlSerializer parsing method.
- Add new class Sequence<T>.
- Class Flated<T> is obsolete, use Sequence<T> instead.
- New feature: Provides JsonXmlSerializer to convert JSON to XmlDocument, or XmlNode to JSON.
- Adjust the EnumOption structure.
- Breaking change: Simplified wrapper type implementation Ref (reference wrapper).
- Breaking change: Add Val type (value wrapper).
- Breaking change: Remove ValueWrapper, use Val instead.
- Breaking change: Remove VString (the value wrapper type for string), use Val<string> instead.
- Breaking change: DateOnlyType and DateTimeType redesigned as Flags.
- New feature: Provide StartOfSeason / EndOfSeason methods for DateOnly / DateTime / DateTimeOffset.
-
Add new class HashMap<TKey, TValue>.
It is a IDictionary type that allows the use of null key.
- DateRangeType has been renamed to DateOnlyType.
- DateTimeRangeType has been renamed to DateTimeType.
- Add new data structure Interval<T> for .NET 7+ to support interval operations.
-
Provide BitConverterEx class for .NET 7+ to support Int128 and UInt128 related methods.
-
Provide calculation support from IPAddress to UInt32 / UInt128.
- IPAddressEx.Create
- IPAddressExtensions.ToUInt32
- IPAddressExtensions.ToUInt128
-
Provide .NET 7 compatibility scheme for DateTime / DateTimeOffset breaking updates:
.NET 7 calculates Ticks algorithms such as AddDays in units of every 1 tick;
.NET 6 and earlier are calculated every 10'000 ticks.
Provide ToFixed extension method for rounding DateTime every 10 ticks using Banker's Rounding.
var dt = new DateTime(2000, 1, 1).AddDays(9.2); // .NET 6-: // 2000/1/10 4:48:00 630830764800000000 ticks // .NET 7+: // 2000/1/10 4:47:59 630830764799999999 ticks var dtf = dt.ToFixed(); // .NET 6-: // 2000/1/10 4:48:00 630830764800000000 ticks // .NET 7+: // 2000/1/10 4:48:00 630830764800000000 ticks
-
Optimize PatternSearch performance, add Locate(s) method to Array to find subsequence index.
-
VariantString has been renamed to Variant.
- New feature: Any.Compose, to create function composition.
- New feature: Any.Chain, Used to transform nested loops to a single loop.
- The extension methods Then / For has been renamed to Pipe .
- New feature: class FixedSizeQueue.
- BREAKING CHANGE: SlidingWindow has been redesigned and renamed to Sliding。
- BREAKING CHANGE: Use StructTuple instead of ValueTuple to provide better compatibility.
- BREAKING CHANGE: Use Any.Zip instead of Zipper member methods.
- BREAKING CHANGE: Use AsIndexValuePairs instead of AsKeyValuePairs / AsKvPairs methods.
- BREAKING CHANGE: Use Any.Forward instead of ObjectExtension.Forward method.
- BREAKING CHANGE: Use Sync instead of SyncLazy type.
- BREAKING CHANGE: Classes LabelValuePair, Zipper, SyncLazy has been removed.
- New feature: class State, to support data binding.
- Adjust precompiled macros to make them more reasonable.
- New feature: Any.Forward, iterate by depth.
- New feature: ArrayExtensions.Map, projects all elements to an array of the new type.
- New feature: Any.Text.ComputeHashCode, Computes a fixed hash of a string.
- Add Any.Zip function instead of Zipper.Create.
- BREAKING CHANGE: To make the name more readable, the extension method class names has been renamed from X... to ...Extensions.
- Add struct HashCode for .NET Framework, which behaves like .NET Core.
- Adjust precompiled macros to make them more reasonable.
Draft
: Features are designed, but not final. Class members may be redesigned.
Finalized
: Features are designed and finalized. It will not be easily modified in the future unless there are major design flaws.
- Class Any.
Name | Description | Status |
---|---|---|
Any.Chain | Convert multiple layers of nested loops to a single-layer chain. | Finalized |
Any.Create | Creates a instance by the specified function. | Finalized |
Any.Flat | Creates a one-dimensional array containing all elements of the specified multidimensional arrays. | Finalized |
Any.Forward | Computes the element by path and returns the element. | Finalized |
Any.ReDim | Reallocates storage space for an array variable. | Finalized |
Any.Text.ComputeHashCode | Computes a deterministic hash code for a string. | Finalized |
Any.Zip | Applies a specified function to the corresponding elements of many sequences, producing a sequence of the results. | Finalized |
- Class DateTimeExtensions or DateTimeOffsetExtensions. (Document)
Name | Description | Status |
---|---|---|
AddDays | Provides a special arithmetic method for calculating working days or non-working days. | Finalized |
AddTotalYears | Returns a new DateTime that adds the specified diff-number of years to the value of this instance. | Finalized |
AddTotalMonths | Returns a new DateTime that adds the specified diff-number of months to the value of this instance. | Finalized |
StartOf & EndOf | Provides operations for the DateTime / DateTimeOffset to return time to a starting point or advance to an end point. | Finalized |
Week | Gets the number of weeks in a year for the specified date. | Finalized |
WeekInMonth | Gets the number of weeks in a month for the specified date. | Finalized |
Class Name | Description | Status |
---|---|---|
DpContainer | Provides dynamic programing feature. | Draft |
Data binding is very useful feature when we need a dynamic variable that depends on other variables.
It can help us maintain only dependent values and achieve the effect of synchronous changes.
Class Name | Description | Status |
---|---|---|
State | Provides data binding feture for instance. | Draft |
Currently, the following functions still need to be improved:
- Compatibility for .NET Framework
- Dynamic formula calculation
- Numerical operations with units
- Dynamic programming
- SequenceInputStream
- And more...
-
Let
Use a method to initialize each element of an array.
var arr = new int[5]; for (int i = 0; i < arr.Length; i++) { arr[i] = i * 2 + 1; }
Simplify:
var arr = new int[5].Let(i => i * 2 + 1);
-
Pipe (No return value)
Run a task for an object, then return itself.
public class AppSecurity { public Aes Aes = Aes.Create(); public AppSecurity() { Aes.Key = "1234567890123456".Bytes(); } }
Simplify:
public class AppSecurity { public Aes Aes = Aes.Create().Pipe(x => x.Key = "1234567890123456".Bytes()); }
-
Pipe(Has return value)
Casts the object to another object through the specified convert method.
var orderYear = Product.Order.Year; var year = orderYear > 2020 ? orderYear : 2020;
Simplify:
var year = Product.Order.Year.Pipe(y => y > 2020 ? y : 2020);