Plinth.Common 1.7.0

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

// Install Plinth.Common as a Cake Tool
#tool nuget:?package=Plinth.Common&version=1.7.0                

README

Plinth.Common

A set of generic utilities, extensions, and enhancements for dotnet applications

Cache

Extensions for atomic GetOrCreate on Microsoft.Extensions.Caching.Memory memory caches Example:

IMemoryCache memCache = MemoryCacheUtil.Create();
await memCache.GetOrCreateAtomicMaxDurationAsync(
	"key", TimeSpan.FromMinutes(2), async () => await LoadValue());

👉 MemoryCacheUtil.Create() is a shorthand method for creating a new IMemoryCache.

Collections

  • Case Insensitive Dictionary and HashSet
  • Default Dictionary that will supply a default value for a key when requested
  • Examples:
// values are case insensitive
var set = new CaseInsensitiveHashSet<string>() { "abc", "ABC" };
set.Contains("aBc"); // true

// LINQ extension
var set = items.Where(...).Select(...).ToCaseInsensitiveHashSet();

// keys are case insensitive
var dict = new CaseInsensitiveDictionary<string, int>() { ["abc"] = 5 };
dict["ABC"]; // 5
dict.ContainsKey("aBc"); // true

// LINQ extension
var dict = items.Where(...).Select(...).ToCaseInsensitiveDictionary(v => v.ID);

// default dictionary, easy counting
var dict = new DefaultDictionary<string, int>(0);
dict["a"]++; // dict["a"] now is 1

// default dictionary, easy multi maps
var dict = new DefaultDictionary<string, ISet<int>>(() => new HashSet<int>());
dict["a"].Add(7); // "a" has a set with (7) in it

Constants

Handy constants for Content Types ContentTypes.ApplicationJson ⇒ "application/json; charset=utf-8"

Exceptions

Logical exceptions for common API return values. Allows for separation between logic and api projects

  • LogicalBadRequestException
  • LogicalConflictException
  • LogicalForbiddenException
  • LogicalNotFoundException
  • LogicalPreconditionFailedException

Extensions

A variety of useful extensions to common classes

  • For manipulating DataRow
  • IDictionary .GetValueOrDefault()
  • IEnumerable .IsNullOrEmpty() and .Many()
  • Enum extensions for converting between enums by name (not by integer value)
  • ILogger extensions for logging code durations
using (log.LogExecTiming("some code"))
{
	... some code ...
	log.Debug("action");
}
// logs
[CTX-6540F] : Starting some code #52400089
[CTX-6540F] : action
[CTX-6540F] : some code #52400089 Took: 00.00.00.274472
  • Sensitive data extensions for masking secure items like passwords, SSNs, and credit card numbers.
  • Stream extensions .ToBytes() and .ToBytesAsync()
  • String extensions for converting strings to various types, .ChangeType<T>() as various .To{Type}OrNull()

Logging

  • Extensions and enhancements to Microsoft.Extensions.ILogger for better tracing when using the Plinth ecosystem
  • Provides StaticLogManager.GetLogger() to retrieve a static logger for the current class
  • Provides RequestTraceId and RequestTraceProperties singletons for passing data through the entire call stack (including across HTTP boundaries)
  • Adds shorthand calls for shorter log function names.
    • LogTrace ⇒ Trace
    • LogDebug ⇒ Debug
    • LogInformation ⇒ Info
    • LogWarning ⇒ Warn
    • LogError ⇒ Error
    • LogCritical ⇒ Critical or Fatal

Mapping

An enhanced version of Omu.ValueInjecter for easy object to object mapping Allows for deeply nested Field to Field mapping (including Lists, Sets, and Dictionaries)

Utils

A set of static utilities

  • AsyncUtil: Some async utilities, mostly obsolete as of net6.0
  • DateTimeUtil: Utilities for truncating date times, UTC/TZ conversions, and some date comparison functions
  • HexUtil: Conversion of hex strings to bytes and vice versa. 👉 Obsolete as of net9.0
  • RuntimeUtil: Provides FindExecutableHome() which can find your project root at runtime
  • TimeUtil: Provides log timing (used by ILogger extension noted above)
  • UriUtil: Provides a Join() method similar to Path.Combine()
Product Compatible and additional computed target framework versions.
.NET 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 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (18)

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

Package Downloads
Plinth.Serialization

JSON/XML/etc object serialization

Plinth.Security

Security, Cryptography, and Token Utilities

Plinth.HttpApiClient.Common

Shared objects for HTTP Api Client frameworks

Plinth.HttpApiClient

HTTP Api Client framework built on MS HttpClient

Plinth.AspNetCore

Plinth ASP.NET Core Services Utilities

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.7.0 445 11/12/2024
1.6.6 465 11/8/2024
1.6.5 1,124 8/31/2024
1.6.4 741 8/2/2024
1.6.3 3,904 5/15/2024
1.6.2 1,219 2/16/2024
1.6.1 5,353 1/5/2024
1.6.0 860 11/30/2023
1.5.10-b186.aca976b4 94 11/30/2023 1.5.10-b186.aca976b4 is deprecated because it is no longer maintained.
1.5.9 2,015 11/29/2023 1.5.9 is deprecated because it is no longer maintained.
1.5.9-b174.64153841 187 11/23/2023 1.5.9-b174.64153841 is deprecated because it is no longer maintained.
1.5.9-b172.dfc6e7bd 100 11/17/2023 1.5.9-b172.dfc6e7bd is deprecated because it is no longer maintained.
1.5.9-b171.4e2b92e2 138 11/4/2023 1.5.9-b171.4e2b92e2 is deprecated because it is no longer maintained.
1.5.8 2,632 10/23/2023 1.5.8 is deprecated because it is no longer maintained.
1.5.7 6,784 7/31/2023 1.5.7 is deprecated because it is no longer maintained.
1.5.6 11,901 7/13/2023 1.5.6 is deprecated because it is no longer maintained.
1.5.5 900 6/29/2023 1.5.5 is deprecated because it is no longer maintained.
1.5.4 2,561 3/7/2023 1.5.4 is deprecated because it is no longer maintained.
1.5.3 1,743 3/3/2023 1.5.3 is deprecated because it is no longer maintained.
1.5.2 2,704 1/11/2023 1.5.2 is deprecated because it is no longer maintained.
1.5.2-b92.7c961f5f 144 1/11/2023 1.5.2-b92.7c961f5f is deprecated because it is no longer maintained.
1.5.0 3,020 11/9/2022 1.5.0 is deprecated because it is no longer maintained.
1.5.0-b88.7a7c20cd 131 11/9/2022 1.5.0-b88.7a7c20cd is deprecated because it is no longer maintained.
1.4.7 12,790 10/20/2022 1.4.7 is deprecated because it is no longer maintained.
1.4.6 6,189 10/17/2022 1.4.6 is deprecated because it is no longer maintained.
1.4.5 6,573 10/1/2022 1.4.5 is deprecated because it is no longer maintained.
1.4.4 11,650 8/16/2022 1.4.4 is deprecated because it is no longer maintained.
1.4.3 6,955 8/2/2022 1.4.3 is deprecated because it is no longer maintained.
1.4.2 6,713 7/19/2022 1.4.2 is deprecated because it is no longer maintained.
1.4.2-b80.7fdbfd04 159 7/19/2022 1.4.2-b80.7fdbfd04 is deprecated because it is no longer maintained.
1.4.2-b74.acaf86f5 209 6/15/2022 1.4.2-b74.acaf86f5 is deprecated because it is no longer maintained.
1.4.1 6,851 6/13/2022 1.4.1 is deprecated because it is no longer maintained.
1.4.0 6,645 6/6/2022 1.4.0 is deprecated because it is no longer maintained.
1.3.8 8,854 4/12/2022 1.3.8 is deprecated because it is no longer maintained.
1.3.7 6,742 3/21/2022 1.3.7 is deprecated because it is no longer maintained.
1.3.6 6,706 3/17/2022 1.3.6 is deprecated because it is no longer maintained.
1.3.6-b67.ca5053f3 174 3/16/2022 1.3.6-b67.ca5053f3 is deprecated because it is no longer maintained.
1.3.6-b66.4a9683e6 160 3/16/2022 1.3.6-b66.4a9683e6 is deprecated because it is no longer maintained.
1.3.5 6,571 2/23/2022 1.3.5 is deprecated because it is no longer maintained.
1.3.4 7,056 1/20/2022 1.3.4 is deprecated because it is no longer maintained.
1.3.3 3,292 12/29/2021 1.3.3 is deprecated because it is no longer maintained.
1.3.2 3,263 12/11/2021 1.3.2 is deprecated because it is no longer maintained.
1.3.1 3,404 11/12/2021 1.3.1 is deprecated because it is no longer maintained.
1.3.0 3,503 11/8/2021 1.3.0 is deprecated because it is no longer maintained.
1.2.3 4,842 9/22/2021 1.2.3 is deprecated because it is no longer maintained.
1.2.2 3,974 8/20/2021 1.2.2 is deprecated because it is no longer maintained.
1.2.1 4,347 8/5/2021 1.2.1 is deprecated because it is no longer maintained.
1.2.0 13,352 8/1/2021 1.2.0 is deprecated because it is no longer maintained.
1.2.0-b37.a54030b9 189 6/24/2021 1.2.0-b37.a54030b9 is deprecated because it is no longer maintained.
1.1.6 11,782 3/22/2021 1.1.6 is deprecated because it is no longer maintained.
1.1.5 4,000 3/9/2021 1.1.5 is deprecated because it is no longer maintained.
1.1.4 4,966 2/27/2021 1.1.4 is deprecated because it is no longer maintained.
1.1.3 3,520 2/17/2021 1.1.3 is deprecated because it is no longer maintained.
1.1.2 3,540 2/12/2021 1.1.2 is deprecated because it is no longer maintained.
1.1.1 3,776 2/1/2021 1.1.1 is deprecated because it is no longer maintained.
1.1.0 3,499 12/16/2020 1.1.0 is deprecated because it is no longer maintained.
1.1.0-b27.b66c309b 314 11/15/2020 1.1.0-b27.b66c309b is deprecated because it is no longer maintained.
1.0.12 5,914 10/18/2020 1.0.12 is deprecated because it is no longer maintained.
1.0.11 3,651 10/6/2020 1.0.11 is deprecated because it is no longer maintained.
1.0.10 3,740 9/30/2020 1.0.10 is deprecated because it is no longer maintained.
1.0.9 3,561 9/29/2020 1.0.9 is deprecated because it is no longer maintained.
1.0.8 3,585 9/26/2020 1.0.8 is deprecated because it is no longer maintained.
1.0.7 3,569 9/19/2020 1.0.7 is deprecated because it is no longer maintained.
1.0.6 3,516 9/3/2020 1.0.6 is deprecated because it is no longer maintained.
1.0.5 3,660 9/2/2020 1.0.5 is deprecated because it is no longer maintained.
1.0.4 3,781 9/1/2020 1.0.4 is deprecated because it is no longer maintained.
1.0.3 3,424 9/1/2020 1.0.3 is deprecated because it is no longer maintained.
1.0.2 3,440 8/29/2020 1.0.2 is deprecated because it is no longer maintained.
1.0.1 3,440 8/29/2020 1.0.1 is deprecated because it is no longer maintained.
1.0.0 3,481 8/29/2020 1.0.0 is deprecated because it is no longer maintained.
1.0.0-b1.c22f563d 270 8/28/2020 1.0.0-b1.c22f563d is deprecated because it is no longer maintained.

net9.0 support