Trivial 1.1.0

.NET Standard 2.0
Suggested Alternatives

Trivial 6.0.0

Additional Details

Please update to the latest version.

There is a newer version of this package available.
See the version list below for details.
dotnet add package Trivial --version 1.1.0
NuGet\Install-Package Trivial -Version 1.1.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="Trivial" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Trivial --version 1.1.0
#r "nuget: Trivial, 1.1.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 Trivial as a Cake Addin
#addin nuget:?package=Trivial&version=1.1.0

// Install Trivial as a Cake Tool
#tool nuget:?package=Trivial&version=1.1.0


This library includes utilities and services for tasks, IO, security, etc.


Just add following namespace to your code file to use.

using Trivial.Tasks;


Maybe a handler will be asked to process several times in a short time but you just want to process once at the last time because the previous ones are obsolete. A sample is real-time search. You can use following method to do so.

// An action you need to process.
Action action = () => {
    // Do something...

// Set up when the action can be processed.
var task = HitTask.Debound(action, TimeSpan.FromMilliseconds(200));

// Somewhere to raise.


A handler to be frozen for a while after it has processed.

var task = HitTask.Throttle(action, TimeSpan.FromMilliseconds(10000));


A handler to process for the specific times and it will be reset after a while.

var task = HitTask.Multiple(action, 10, null, TimeSpan.FromMilliseconds(200));


A handler to process for the specific times only and it will be reset after a while. A sample is double click.

var task = HitTask.Times(action, 2, 2, TimeSpan.FromMilliseconds(200));


You can create a linear retry policy or even a customized to process an action with the specific retry policy. And you can use ObservableTask to observe the state of an action processing.


Just add following namespace to your code file to use.

using Trivial.Maths;


There a lot of arithmetic functions.

Arithmetic.IsPrime(2147483647); // True
await Arithmetic.IsPrimeAsync(2305843009213693951); // False

Arithmetic.Factorial(10); // 3628800

Arithmetic.Gcd(192, 128); // 64
Arithmetic.Lcm(192, 128); // 384


You can get the number symbols as you want.

You can also get the number string in English words.

// twelve thousand three hundred and forty-five point six seven

// 1.2M

And ChineseNumerals for Chinese and JapaneseNumerals for Japanese.

Angle and polar point

  • Angle Angle.
  • PolarPoint The point in polar coordinates.


  • NullableValueSimpleInterval<T> Interval, such as [20, 100).

Rectangular coordinates

  • OneDimensionalPoint The point in 1D (line) coordinates.
  • TwoDimensionalPoint The point in 2D (flat) coordinates.
  • ThreeDimensionalPoint The point in 3D (stereoscophic) coordinates.
  • FourDimensionalPoint The point in 4D (spacetime) coordinates.


Contains the helper functions and extension functions for network, such as HTTP web client and its content.

using Trivial.Net;

And you can also use JsonHttpClient to serialize the JSON format response with retry policy supports. And HttpUri for HTTP URI fields accessing.


Just add following namespace to your code file to use.

using Trivial.Security;


You can convert a PEM (OpenSSL RSA key) or an XML string to the RSAParametersConvert class.

var parameters = RSAParametersConvert.Parse(pem);

And you can convert back by using the extension method ToPrivatePEMString or ToPublicPEMString. And also you can use the extension method ToXElement to export the XML.


You can encrypt and decrypt a string by symmetric algorithm.

// AES sample.
var original = "Original secret string";
var cipher = SymmetricUtilities.Encrypt(Aes.Create, original, key, iv);
var back = SymmetricUtilities.DecryptText(Aes.Create, cipher, key, iv); // back == original


For hash algorithm, you can call HashUtilities.ToHashString function to get hash from a plain string and call HashUtilities.Verify to verify.

var original = "The string to hash";

// SHA-512 (of SHA-2 family)
var sha512Str = HashUtilities.ToHashString(SHA512.Create, original);
var isVerified = HashUtilities.Verify(SHA512.Create, original, sha512Str); // --> true

// SHA-3-512
var sha3512Str = HashUtilities.ToHashString(new HashAlgorithmName("SHA3512"), original);
var isVerified3512 = HashUtilities.Verify(sha3512Name, original, sha3512Str); // --> true

Access token

We also provide a set of tools for OAuth including following models.

  • TokenInfo The access token and other properties.
  • AppAccessingKey The app identifier and secret key.
  • OAuthClient The token container with the ability to resolve the access token and create the JSON HTTP web client to access the resources required authentication.

And you can also implement the OAuthBasedClient base class to create your own business HTTP web client factory with OAuth supports.

Secure string utiltiy

You can use the extension methods in the SecureStringExtensions class to convert the secret between SecureString and String/StringBuilder/Byte[].

You can also use the class RSASecretExchange to transfer the secret with RSA encryption.


You can create a JSON web token to get the string encoded by initializing a new instance of the JsonWebToken class or the JsonWebTokenParser class.

var sign = HashSignatureProvider.CreateHS512("a secret string");
var jwt = new JsonWebToken<Model>(new Model(), sign);
var jwtStr = jwt.ToEncodedString();

// Get authenticiation header value.
var header = jwt.ToAuthenticationHeaderValue();

// Parse.
var jwtSame = JsonWebToken<Model>.Parse(jwtStr, sign); // jwtSame.ToEncodedString() == jwtStr


Contains the helper functions and extension methods for FileInfo and Stream.

using Trivial.IO;

Characters reader

You can read text from a character collection or a number of stream by CharsReader class.


Contains lots of data readers, parsers and utilities.

using Trivial.Data;


You can parse a CSV text by following way.

var csv = new CsvParser("abcd,efg\nhijk,lmn");
foreach (var item in csv)
    Console.WriteLine("{0},{1}", item[0], item[1]);

If you have a model like following.

class Model
    public string A { get; set; }
    public string B { get; set; }

Now you can map to the CSV file.

foreach (var model in csv.ConvertTo<Model>(new[] { "A", "B" }))
    Console.WriteLine("{0},{1}", model.A, model.B);

Data cache collection

You can create a collection to cache data with expiration and count limitation by following way.

var cache = new DataCacheCollection<Model>
    MaxCount = 1000,
    Expiration = TimeSpan.FromSeconds(100)

So that you can get the data from the cache if has and or add new one if necessary.

if (!cache.TryGet("abcd", out Model item)) item = new Model();


Contains the models of geography.

using Trivial.Geography;


You can use Geolocation, Latitude, Longitude and other models for geolocation information.

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. 
.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)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (8)

Showing the top 5 NuGet packages that depend on Trivial:

Package Downloads

The rich user interface console controls and utilities.


Some advanced visual controls and utilities for Windows app.


A core library of NuScien framework which provides a solution to build community and enterprise projects based on resource entity and accessories with ACL and CMS built-in.


A library with basic chemical models.


A library for web API.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
7.1.2 89 5/10/2023
7.1.1 56 5/10/2023
7.1.0 80 5/8/2023
7.0.0 720 1/20/2023
6.6.0 2,136 11/9/2022
6.5.6 687 10/10/2022
6.5.5 295 10/9/2022
6.5.4 645 8/10/2022
6.5.0 354 6/17/2022
6.4.0 2,180 4/14/2022
6.3.0 1,446 3/8/2022
6.2.0 2,961 1/30/2022
6.1.0 1,396 1/23/2022
6.0.0 828 1/1/2022
5.2.0 2,687 12/15/2021
5.1.1 302 12/3/2021
5.1.0 840 12/2/2021
5.0.0 819 11/27/2021
4.0.0 641 11/9/2021
3.9.0 754 12/15/2021
3.8.0 716 11/9/2021
3.7.2 6,315 4/22/2021
3.7.0 1,095 3/17/2021
3.6.2 536 3/17/2021
3.6.0 5,551 11/12/2020
3.5.2 5,962 4/13/2020
3.5.1 1,051 4/12/2020
3.5.0 1,047 4/1/2020
3.4.3 988 3/20/2020
3.4.2 968 3/12/2020
3.4.1 1,011 2/25/2020
3.4.0 1,292 2/20/2020
3.3.0 1,364 2/14/2020
3.2.0 1,693 1/22/2020
3.1.0 1,731 12/30/2019
3.0.1 1,582 12/26/2019
2.2.0 802 2/19/2020
2.1.0 1,280 12/24/2019
2.0.3 1,148 12/3/2019
1.2.0 17,116 5/20/2019
1.1.0 1,709 5/8/2019
1.0.0 3,742 5/1/2019