Universal.Common 8.3.3

dotnet add package Universal.Common --version 8.3.3
                    
NuGet\Install-Package Universal.Common -Version 8.3.3
                    
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="Universal.Common" Version="8.3.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Universal.Common" Version="8.3.3" />
                    
Directory.Packages.props
<PackageReference Include="Universal.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 Universal.Common --version 8.3.3
                    
#r "nuget: Universal.Common, 8.3.3"
                    
#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.
#addin nuget:?package=Universal.Common&version=8.3.3
                    
Install as a Cake Addin
#tool nuget:?package=Universal.Common&version=8.3.3
                    
Install as a Cake Tool

Universal.Common

Support utilities and extensions meant to extend the default functionality from the base class library.

Classes

BinaryReader

Endianness-aware implementation of System.IO.BinaryReader, allowing to read primitive types from a stream in big-endian or little-endian byte order.

using (var stream = new FileStream("file.bin", FileMode.Open, FileAccess.Read))
{
    // Create a BinaryReader with big-endian byte order
    using (var reader = new BinaryReader(stream, Endian.Big))
    {
        // Read an Int32 in big-endian order
        int value = reader.ReadInt32();
    }
}

BinaryWriter

Endianness-aware implementation of System.IO.BinaryWriter, allowing to write primitive types to a stream in big-endian or little-endian byte order.

using (var stream = new FileStream("file.bin", FileMode.Create, FileAccess.Write))
{
    // Create a BinaryWriter with big-endian byte order
    using (var writer = new BinaryWriter(stream, Endian.Big))
    {
        // Write an Int32 in big-endian order
        writer.Write(1234567890);
    }
}

BitSequence

Utility for as-is bit manipulations.

BitSequence bs1 = new BitSequence("10001010"); // Binary representation in string.
BitSequence bs2 = new BitSequence(new bool[] { true, false, true }); // As booleans.
BitSequence bs3 = bs1 & "11110000"; // Bitwise and, implicit conversion from binary representation string.

BitStream

Utility to perform bit-level operations on System.IO.Stream.

using (BitStream bitStream = new BitStream(stream)) 
{
    uint value = bitStream.ReadUInt32(4); // Reads 4 bits from the stream and interprets it as an unsigned integer, padding if necessary.
}

MediaType

Represents MIME types and provides functionality for working with media types in various contexts.

Constructor
MediaType mediaType = new MediaType("application/json");
MediaType Detection

The MediaType class provides several static methods to create MediaType instances from different sources:

  1. FromExtension
MediaType mediaType = MediaType.FromExtension(".json");
// Returns a MediaType instance for "application/json"

Creates a MediaType instance based on a file extension (with or without the leading dot).

  1. FromByteArray
byte[] fileBytes = File.ReadAllBytes("sample.png");
MediaType mediaType = MediaType.FromByteArray(fileBytes);
// Returns a MediaType instance for "image/png"

Detects the media type based on the file signature in the byte array.

  1. FromStream
using (FileStream stream = File.OpenRead("sample.jpg"))
{
    MediaType mediaType = MediaType.FromStream(stream);
    // Returns a MediaType instance for "image/jpeg"
}

Detects the media type based on the file signature read from the stream.

These methods allow for flexible media type detection from various sources, making it easier to work with files and data streams in different formats.

SemanticVersion

Implements version numbers that follow the Semantic Versioning 2.0.0 specification (https://semver.org/). Supports major, minor, and patch version components along with pre-release identifiers and build metadata.

// Basic version
var version = new SemanticVersion(1, 2, 3); // 1.2.3

// Version with pre-release and build metadata
var version = new SemanticVersion(1, 2, 3, "alpha.1", "build.123"); // 1.2.3-alpha.1+build.123

// Parse from string
SemanticVersion version = SemanticVersion.Parse("2.0.0-rc.1+build.123");

// Version comparison follows SemVer rules
Assert.IsTrue(SemanticVersion.Parse("1.0.0-alpha") < SemanticVersion.Parse("1.0.0"));
Assert.IsTrue(SemanticVersion.Parse("1.0.0-alpha.1") < SemanticVersion.Parse("1.0.0-alpha.2"));

StreamSegment

Represents a segment of a Stream that is itself a stream. This allows you to work with a specific portion of a stream as if it were a separate stream.

using (var stream = new FileStream("file.bin", FileMode.Open, FileAccess.Read))
{
    // Create a StreamSegment that represents the first 1024 bytes of the stream
    using (var segment = new StreamSegment(stream, 0, 1024))
    {
        // Read the first 1024 bytes of the stream
        byte buffer = new byte;
        segment.Read(buffer, 0, 1024);
    }
}

UriBuilder

Derived from System.UriBuilder, this class provides a fluent API to configure segments and queries.

UriBuilder uriBuilder = new UriBuilder("http://www.myhost.com");
uriBuilder
    .AddSegments("api", "Product", 1)
    .AddQuery("key", "value");
// "https://www.myhost.com/api/Product/1?key=value"

ZigZag

Static class that encodes arrays to matrices and vice-versa.

int[,] matrix = new int[,] { { 0, 1 }, { 2, 3 } };
int[] array = ZigZag.ToArray(matrix); // [0, 1, 2, 3]
Product 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 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 was computed.  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.
  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net6.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (31)

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

Package Downloads
Universal.Common.Reflection

Class library for performing advanced operations with types, dynamic objects, expressions, and reflection.

Universal.Common.Net.Http

Class library to build clients and work with HTTP web services.

Universal.Common.Serialization

Class library with base objects that provide serializable to and from XML and JSON strings and binary serialization using the native binary formatter.

Universal.Android

Class library for accelerating Xamarin.Android development. Note: If you encounter layout inflation exceptions (could be masked as NotFoundException, or some issue with text_color_secondary.xml etc), make sure you define colorControlNormal and use a style with that attribute defined.

Universal.Common.Mathematics

Class library implementing advanced mathematical algorithms, transforms, and time series manipulations. Implementations favour simplicity and correctness.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
8.3.3 5,324 2/22/2025
8.3.2 191 2/22/2025
8.3.1 205 2/16/2025
8.3.0 115 2/15/2025
8.2.5 1,638 10/17/2024
8.2.4.1 1,466 7/15/2024
8.2.4 17,561 9/25/2023
8.2.3 1,395 6/8/2023
8.2.2 2,570 11/23/2022
8.2.1 421 11/22/2022
8.2.0 11,370 9/14/2022
8.1.2 23,343 10/24/2021
8.1.1 514 10/23/2021
8.1.0 520 10/23/2021
8.0.0 14,018 10/13/2021
7.7.1 7,380 8/24/2021
7.7.0 452 8/24/2021
7.6.2 497 8/19/2021
7.6.1 13,099 6/17/2021
7.6.0 2,326 6/3/2021
7.5.7 2,981 4/30/2021
7.5.6 498 4/29/2021
7.5.5 749 4/13/2021
7.5.4 9,390 3/31/2021
7.5.3 6,253 3/21/2021
7.5.2 1,355 3/15/2021
7.5.1 941 2/16/2021
7.5.0 32,918 2/5/2021
7.4.6 551 2/2/2021
7.4.5.1 2,045 1/15/2021
7.4.5 1,174 1/13/2021
7.4.4 1,730 1/7/2021
7.4.3 2,074 12/16/2020
7.4.2.1 622 12/15/2020
7.4.2 594 12/9/2020
7.4.1 5,527 11/26/2020
7.4.0 584 11/26/2020
7.3.5 2,876 11/23/2020
7.3.4 1,840 11/11/2020
7.3.3 614 11/11/2020
7.3.2 1,408 11/1/2020
7.3.1.1 4,770 10/19/2020
7.3.1 603 10/15/2020
7.3.0 598 10/15/2020
7.2.2 3,559 9/29/2020
7.2.1 731 9/29/2020
7.2.0 601 9/29/2020
7.1.1.1 665 9/28/2020
7.1.1 702 9/25/2020
7.1.0 1,839 9/2/2020
7.0.0 6,287 8/24/2020
6.4.7 684 8/21/2020
6.4.6 675 8/21/2020
6.4.5 20,246 5/21/2020
6.4.4 1,954 5/12/2020
6.4.3 2,141 4/23/2020
6.4.2 634 4/20/2020
6.4.1.2 18,666 3/20/2020
6.4.1.1 703 3/20/2020
6.4.1 684 3/20/2020
6.4.0 5,961 2/25/2020
6.3.5 1,312 2/21/2020
6.3.4 749 2/21/2020
6.3.3 3,748 2/11/2020
6.3.2 746 2/11/2020
6.3.1.1 7,259 1/23/2020
6.3.0 4,299 12/18/2019
6.2.7 2,245 12/17/2019
6.2.6 1,374 12/4/2019
6.2.5 881 12/4/2019
6.2.4 3,512 12/1/2019
6.2.3 10,470 10/25/2019
6.2.2 3,576 10/8/2019
6.2.1 1,132 10/7/2019
6.2.0.1 5,463 9/25/2019
6.2.0 1,848 9/20/2019
6.1.5 3,228 9/16/2019
6.1.4.1 1,755 9/9/2019
6.1.4 2,197 9/3/2019
6.1.3 712 9/2/2019
6.1.2 899 8/28/2019
6.1.1 7,646 7/9/2019
6.1.0.1 30,049 7/5/2019
6.1.0 16,962 5/7/2019
6.0.6 1,897 5/3/2019
6.0.5 1,414 5/2/2019
6.0.4 4,794 4/24/2019
6.0.3 1,072 4/24/2019
6.0.2 7,886 3/22/2019
6.0.1.2 2,452 3/12/2019
6.0.1.1 932 3/12/2019
6.0.1 940 3/11/2019
6.0.0 1,721 3/6/2019
5.3.6 869 3/5/2019
5.3.5 837 3/5/2019
5.3.4 1,924 3/4/2019
5.3.3 1,544 2/28/2019
5.3.2 1,365 2/27/2019
5.3.1.1 961 2/25/2019
5.3.1 852 2/25/2019
5.3.0 813 2/25/2019
5.2.1 3,421 2/16/2019
5.2.0.1 3,912 2/7/2019
5.1.8 887 2/7/2019
5.1.7.1 1,121 1/30/2019
5.1.7 900 1/30/2019
5.1.6.1 910 1/24/2019
5.1.6 872 1/23/2019
5.1.5 880 1/23/2019
5.1.4.2 936 1/18/2019
5.1.3 1,629 1/14/2019
5.1.2 7,720 1/8/2019
5.1.1.1 913 1/8/2019
5.1.1 897 1/6/2019
5.1.0 1,518 1/2/2019
5.0.2 931 12/31/2018
5.0.1.1 912 12/31/2018
5.0.1 900 12/31/2018
5.0.0.1 1,042 12/14/2018
5.0.0 2,203 12/10/2018
4.2.5 972 11/23/2018
4.2.4 986 11/23/2018
4.2.3.1 955 11/22/2018
4.2.3 944 11/22/2018
4.2.2.2 1,217 11/19/2018
4.2.2.1 8,330 10/2/2018
4.2.2 1,041 10/1/2018
4.2.1.2 1,056 10/1/2018
4.2.1.1 1,032 9/27/2018
4.2.1 968 9/26/2018
4.2.0.5 1,030 9/26/2018
4.2.0.4 1,012 9/25/2018
4.2.0.3 1,041 9/25/2018
4.2.0.2 1,060 9/25/2018
4.2.0.1 1,022 9/25/2018
4.2.0 1,147 9/24/2018
4.1.0 992 9/21/2018
4.0.0.6 1,029 9/18/2018
4.0.0.5 1,070 9/18/2018
4.0.0.4 1,039 9/17/2018
4.0.0.3 3,360 9/7/2018
4.0.0.2 1,311 9/4/2018
4.0.0.1 1,418 9/4/2018
4.0.0 4,206 8/30/2018
3.2.0 2,924 8/28/2018
3.1.0 1,036 8/28/2018
3.0.6 2,620 8/27/2018
3.0.5 1,020 8/27/2018
3.0.4 1,057 8/27/2018
3.0.3 1,060 8/24/2018
3.0.2 1,260 8/24/2018
3.0.1.2 1,034 8/23/2018
3.0.1.1 1,090 8/21/2018
3.0.1 1,055 8/21/2018
3.0.0 1,971 8/16/2018
2.2.1 1,129 8/15/2018
2.2.0 1,081 8/14/2018
2.1.0 1,081 8/13/2018
2.0.2 1,166 8/7/2018
2.0.1 1,499 5/10/2018
2.0.0 2,089 4/26/2018
1.5.3.7 3,316 1/27/2018
1.5.3.6 1,384 1/15/2018
1.5.3.5 1,360 1/8/2018
1.5.3.4 1,361 1/3/2018
1.5.3.3 1,383 1/3/2018
1.5.3.2 1,370 12/27/2017
1.5.3.1 1,392 12/25/2017
1.5.3 1,329 12/25/2017
1.5.2 1,354 12/24/2017
1.5.1 1,375 12/23/2017
1.5.0 1,324 12/22/2017
1.4.7 1,138 12/2/2017
1.4.6 2,770 11/28/2017
1.4.5 1,330 11/28/2017
1.4.0 1,398 11/12/2017
1.3.5 4,062 11/8/2017
1.3.4 1,400 11/8/2017
1.3.3 1,466 11/2/2017
1.3.2 1,394 11/2/2017
1.3.1 1,430 9/12/2017
1.3.0 1,343 8/26/2017
1.2.1 1,228 8/23/2017
1.2.0 1,300 8/17/2017
1.1.1 1,226 8/17/2017
1.1.0 1,228 8/17/2017
1.0.0 2,040 8/12/2017

Added new SemanticVersion type.