TmEssentials 2.4.2

dotnet add package TmEssentials --version 2.4.2
NuGet\Install-Package TmEssentials -Version 2.4.2
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="TmEssentials" Version="2.4.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TmEssentials --version 2.4.2
#r "nuget: TmEssentials, 2.4.2"
#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 TmEssentials as a Cake Addin
#addin nuget:?package=TmEssentials&version=2.4.2

// Install TmEssentials as a Cake Tool
#tool nuget:?package=TmEssentials&version=2.4.2

Trackmania Essentials

Nuget GitHub release (latest by date including pre-releases) Code Coverage

A super light-weight library that provides formatting features.

Time formatting

Two new structs: TimeInt32 and TimeSingle

  • Storage size is half smaller than with TimeSpan.
  • Reduced floating point errors, previously caused by double/float casting.
  • Struct methods are nearly the same to TimeSpan.
  • Consistency is partially covered by the ITime interface.
  • Implicitly modified ToString() to use a Trackmania-familiar format.
  • ToTmString() extension methods for consistency reasons (due to nullable value types).

Example usage of TimeInt32:

TimeInt32 time = new TimeInt32(TotalMilliseconds: 36217);
string formattedTime = time.ToTmString(); // ToString() acts the same
Console.WriteLine(formattedTime); // Output: 0:36.217

string formattedTimeUsingHundredths = time.ToTmString(useHundredths: true);
Console.WriteLine(formattedTimeUsingHundredths); // Output: 0:36.21

string formattedTimeUsingApostrophe = time.ToTmString(useApostrophe: true);
Console.WriteLine(formattedTimeUsingApostrophe); // Output: 0'36''217

TimeInt32? noTime = null;
string formattedNoTime = noTime.ToTmString();
Console.WriteLine(formattedNoTime); // Output: -:--.---

string formattedNoTimeUsingHundredths = noTime.ToTmString(useHundredths: true);
Console.WriteLine(formattedNoTimeUsingHundredths); // Output: -:--.--

string formattedNoTimeUsingApostrophe = noTime.ToTmString(useApostrophe: true);
Console.WriteLine(formattedNoTimeUsingApostrophe); // Output: -'--''---

Example usage of TimeSingle:

TimeSingle time = new TimeSingle(TotalSeconds: 23.51f);
string formattedTime = time.ToTmString();
Console.WriteLine(formattedTime); // Output: 0:23.510

string formattedTimeUsingHundredths = time.ToTmString(useHundredths: true);
Console.WriteLine(formattedTimeUsingHundredths); // Output: 0:23.51

string formattedTimeUsingApostrophe = time.ToTmString(useApostrophe: true);
Console.WriteLine(formattedTimeUsingApostrophe); // Output: 0'23''510

TimeSingle? noTime = null;
string formattedNoTime = noTime.ToTmString();
Console.WriteLine(formattedNoTime); // Output: -:--.---

string formattedNoTimeUsingHundredths = noTime.ToTmString(useHundredths: true);
Console.WriteLine(formattedNoTimeUsingHundredths); // Output: -:--.--

string formattedNoTimeUsingApostrophe = noTime.ToTmString(useApostrophe: true);
Console.WriteLine(formattedNoTimeUsingApostrophe); // Output: -'--''---

Formatting extensions for TimeSpan

  • Same formatting features like TimeInt32/TimeSingle has but on TimeSpan.
  • TimeSpanExtensions.ToMilliseconds() - Total milliseconds as integer value with truncated ticks.

Text formatting

Currently only deformat.

Credits to Tom and Stefan Baumann for their effective Regex pattern.

TextFormatter.Deformat()

var formatted = "$F00T$D01M$C13U$A14.$815K$727r$528a$329z$23By$03CC$03Co$04Bl$059o$068r$077s$085 $094v$0A30$0B1.$0C01";
var deformatted = TextFormatter.Deformat(formatted);
Console.WriteLine(deformatted);

// Output: TMU.KrazyColors v0.1

ANSI formatting of Trackmania string

Credits to reaby for the solution.

var formatted = "$F00T$D01M$C13U$A14.$815K$727r$528a$329z$23By$03CC$03Co$04Bl$059o$068r$077s$085 $094v$0A30$0B1.$0C01";
var ansiFormatted = TextFormatter.FormatAnsi(formatted);

// Rough output: \\u001b[1;31mT\\u001b[1;31mM\\u001b[1;31mU\\u001b[0;31m.\\u001b[0;35mK\\u001b[0;35mr\\u001b[0;34ma\\u001b[0;34mz\\u001b[1;34my\\u001b[0;34mC\\u001b[0;34mo\\u001b[0;34ml\\u001b[0;36mo\\u001b[0;36mr\\u001b[0;36ms\\u001b[0;32m \\u001b[0;32mv\\u001b[0;32m0\\u001b[0;32m.\\u001b[0;32m1\\u001b[39m\\u001b[22m

[image soon]

Accounts formatting

Currently only has a very efficient account ID/login converter.

AccountUtils.ToAccountId()

AccountUtils.ToAccountId("v89i_w-eQKq5JBG5xwuKCQ") // "bfcf62ff-0f9e-40aa-b924-11b9c70b8a09"

AccountUtils.ToLogin()

AccountUtils.ToLogin(Guid.Parse("bfcf62ff-0f9e-40aa-b924-11b9c70b8a09")) // "v89i_w-eQKq5JBG5xwuKCQ"

.NET Standard 2+

HttpClientExtensions.HeadAsync(string requestUri, CancellationToken cancellationToken = default)

Implements the HEAD request into a simple method. HEAD request is useful for getting the last modified date.

Benchmarks

The library tries to be as effective as possible to an absurd level with using managed code only.

BenchmarkDotNet v0.13.11, Windows 11 (10.0.22621.2861/22H2/2022Update/SunValley2)
AMD Ryzen 7 3700X, 1 CPU, 16 logical and 8 physical cores
.NET SDK 8.0.100
  [Host]     : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2 [AttachedDebugger]
  DefaultJob : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2


| Method                                                   | Mean       | Error     | StdDev    | Median     | Gen0   | Allocated |
|--------------------------------------------------------- |-----------:|----------:|----------:|-----------:|-------:|----------:|
| 'Null with hundredths'                                   |  0.2379 ns | 0.0154 ns | 0.0144 ns |  0.2363 ns |      - |         - |
| 'Null with milliseconds'                                 |  1.9493 ns | 0.0123 ns | 0.0103 ns |  1.9540 ns |      - |         - |
| 'Seconds and milliseconds only'                          | 30.5358 ns | 0.6123 ns | 1.0884 ns | 29.9976 ns | 0.0048 |      40 B |
| '1-digit minute, seconds and milliseconds only'          | 30.5601 ns | 0.6134 ns | 0.5122 ns | 30.4337 ns | 0.0048 |      40 B |
| '2-digit minute, seconds and hundredths only'            | 30.6992 ns | 0.2823 ns | 0.2358 ns | 30.6543 ns | 0.0048 |      40 B |
| 'Milliseconds only'                                      | 30.9590 ns | 0.6381 ns | 0.8734 ns | 30.9244 ns | 0.0048 |      40 B |
| 'Hundredths only'                                        | 31.0166 ns | 0.6434 ns | 1.1098 ns | 30.7131 ns | 0.0048 |      40 B |
| 'Negative seconds and hundredths only'                   | 31.5512 ns | 0.6633 ns | 0.7896 ns | 31.3869 ns | 0.0048 |      40 B |
| '1-digit minute, seconds and hundredths only'            | 31.6155 ns | 0.5243 ns | 0.5149 ns | 31.6675 ns | 0.0048 |      40 B |
| 'Seconds and hundredths only'                            | 31.8579 ns | 0.6069 ns | 1.0140 ns | 31.6990 ns | 0.0048 |      40 B |
| 'Negative milliseconds only'                             | 31.9256 ns | 0.3962 ns | 0.3513 ns | 31.8951 ns | 0.0048 |      40 B |
| '2-digit minute, seconds and milliseconds only'          | 31.9811 ns | 0.6515 ns | 0.8698 ns | 31.6213 ns | 0.0048 |      40 B |
| 'Negative hundredths only'                               | 31.9918 ns | 0.6653 ns | 0.7395 ns | 31.8978 ns | 0.0048 |      40 B |
| 'Negative 1-digit minute, seconds and milliseconds only' | 32.0097 ns | 0.6535 ns | 0.8498 ns | 31.7147 ns | 0.0048 |      40 B |
| 'Negative 2-digit minute, seconds and milliseconds only' | 32.2230 ns | 0.6680 ns | 0.7424 ns | 32.1323 ns | 0.0057 |      48 B |
| 'Negative 1-digit minute, seconds and hundredths only'   | 32.3645 ns | 0.6732 ns | 0.8014 ns | 32.2189 ns | 0.0048 |      40 B |
| 'Negative seconds and milliseconds only'                 | 33.3655 ns | 0.6869 ns | 1.2902 ns | 33.0008 ns | 0.0048 |      40 B |
| 'Negative 2-digit minute, seconds and hundredths only'   | 33.8375 ns | 0.4832 ns | 0.4284 ns | 33.8595 ns | 0.0048 |      40 B |
| 'Hours, minutes, seconds and hundredths only'            | 38.0449 ns | 0.7887 ns | 0.6991 ns | 37.9283 ns | 0.0057 |      48 B |
| 'Hours, minutes, seconds and milliseconds only'          | 38.2250 ns | 0.7767 ns | 0.9822 ns | 38.2305 ns | 0.0057 |      48 B |
| 'Negative hours, minutes, seconds and milliseconds only' | 38.2533 ns | 0.4994 ns | 0.4170 ns | 38.3381 ns | 0.0057 |      48 B |
| 'Negative hours, minutes, seconds and hundredths only'   | 38.6611 ns | 0.5701 ns | 0.5333 ns | 38.5405 ns | 0.0057 |      48 B |
| 'Fully-used TimeSpan with hundredths'                    | 40.3112 ns | 0.4293 ns | 0.3806 ns | 40.2566 ns | 0.0057 |      48 B |
| 'Fully-used TimeSpan with milliseconds'                  | 40.4784 ns | 0.8199 ns | 0.8052 ns | 40.3464 ns | 0.0067 |      56 B |
| 'Fully-used negative TimeSpan with milliseconds'         | 40.8930 ns | 0.4993 ns | 0.4670 ns | 40.7865 ns | 0.0067 |      56 B |
| 'Fully-used negative TimeSpan with hundredths'           | 41.2768 ns | 0.6247 ns | 0.5843 ns | 41.3455 ns | 0.0067 |      56 B |
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 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. 
.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 is compatible.  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.
  • .NETFramework 4.6.2

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (8)

Showing the top 5 NuGet packages that depend on TmEssentials:

Package Downloads
GBX.NET

General purpose library for Gbx files - data from Nadeo games like Trackmania or Shootmania. It supports high performance serialization and deserialization of 200+ Gbx classes.

ManiaAPI.Base

Base library for the ManiaAPI projects. Do not use this alone!

ManiaAPI.TMX

Wrapper for the TMX API, currently only on tm-exchange.com. Part of the ManiaAPI library set.

ManiaAPI.NadeoAPI

Wrapper for the official in-game Nadeo API from Trackmania released in 2020. Part of the ManiaAPI library set.

ManiaAPI.TrackmaniaIO

Wrapper for the Trackmania.io API. Part of the ManiaAPI library set.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.4.2 1,134 4/14/2024
2.4.1 773 1/24/2024
2.4.0 982 12/21/2023
2.3.3 404 7/5/2023
2.3.2 6,041 8/30/2022
2.3.1 2,743 8/10/2022
2.3.0 1,583 8/4/2022
2.2.0 1,809 5/30/2022
2.1.3 3,481 4/2/2022
2.1.2 2,351 2/19/2022
2.1.1 389 2/19/2022
2.1.0.2 402 2/18/2022
2.0.0 1,994 8/12/2021
1.0.0 504 7/25/2021