Plinth.Common
1.7.3
Prefix Reserved
See the version list below for details.
dotnet add package Plinth.Common --version 1.7.3
NuGet\Install-Package Plinth.Common -Version 1.7.3
<PackageReference Include="Plinth.Common" Version="1.7.3" />
<PackageVersion Include="Plinth.Common" Version="1.7.3" />
<PackageReference Include="Plinth.Common" />
paket add Plinth.Common --version 1.7.3
#r "nuget: Plinth.Common, 1.7.3"
#:package Plinth.Common@1.7.3
#addin nuget:?package=Plinth.Common&version=1.7.3
#tool nuget:?package=Plinth.Common&version=1.7.3
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
RequestTraceIdandRequestTracePropertiessingletons for passing data through the entire call stack (including across HTTP boundaries) - Adds shorthand calls for shorter log function names.
LogTrace⇒TraceLogDebug⇒DebugLogInformation⇒InfoLogWarning⇒WarnLogError⇒ErrorLogCritical⇒CriticalorFatal
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 | Versions 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. 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. |
-
net6.0
- Microsoft.Extensions.Caching.Memory (>= 9.0.7)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.7)
- Microsoft.SourceLink.Bitbucket.Git (>= 1.1.1)
- System.Text.Json (>= 9.0.7)
- ValueInjecter (>= 3.2.0)
-
net8.0
- Microsoft.Extensions.Caching.Memory (>= 9.0.7)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.7)
- Microsoft.SourceLink.Bitbucket.Git (>= 1.1.1)
- System.Text.Json (>= 9.0.7)
- ValueInjecter (>= 3.2.0)
-
net9.0
- Microsoft.Extensions.Caching.Memory (>= 9.0.7)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.7)
- Microsoft.SourceLink.Bitbucket.Git (>= 1.1.1)
- System.Text.Json (>= 9.0.7)
- ValueInjecter (>= 3.2.0)
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.8.1 | 1,648 | 12/11/2025 | |
| 1.8.0 | 2,352 | 11/13/2025 | |
| 1.8.0-b211.72089fd9 | 271 | 11/12/2025 | |
| 1.7.4 | 7,465 | 8/6/2025 | |
| 1.7.3 | 622 | 8/2/2025 | |
| 1.7.2 | 7,536 | 3/16/2025 | |
| 1.7.1 | 1,889 | 12/12/2024 | |
| 1.7.0 | 7,461 | 11/12/2024 | |
| 1.6.6 | 1,622 | 11/8/2024 | |
| 1.6.5 | 5,217 | 8/31/2024 | |
| 1.6.4 | 1,191 | 8/2/2024 | |
| 1.6.3 | 13,598 | 5/15/2024 | |
| 1.6.2 | 2,005 | 2/16/2024 | |
| 1.6.1 | 9,777 | 1/5/2024 | |
| 1.6.0 | 1,976 | 11/30/2023 | |
| 1.5.10-b186.aca976b4 | 163 | 11/30/2023 | |
| 1.5.9 | 5,378 | 11/29/2023 | |
| 1.5.9-b174.64153841 | 601 | 11/23/2023 | |
| 1.5.9-b172.dfc6e7bd | 175 | 11/17/2023 | |
| 1.5.9-b171.4e2b92e2 | 250 | 11/4/2023 |
net9.0 support