Core reusable definitions for .NET Core and .NET Framework
$ dotnet add package SonghayCoreThe Core code to install as a NuGet package for all of my studio Solutions. Anyone who may be reading this 👀 is free to do the same. This package is based on a project file that supports multi-targeting, declaring support for net8.0.
NuGet package 📦: SonghayCore
documentation 📚: SonghayCore API
coverlet test coverage 🔬☔: [report]
Songhay.HostingOne of the most important additions to .NET came in .NET 6.0 (circa 2021): the .NET Generic Host [📖 docs]. This host concept from Microsoft allows developers to not have to reinvent:
IHostedService implementations (for long-running background tasks [📖 docs ])All ASP.NET developers expect to get these things “for free” and, finally, Microsoft is basically letting all .NET developers get these things for free. This Core recognizes the .NET Generic Host, stating with the DefaultHostedService class (see Songhay.Extensions below for more details).
Songhay.DiagnosticsThis Core is concerned with tracing as well as logging. Logging concerns should be logically above this Core. TraceSources and TraceSourceExtensions define how tracing should be implemented with a bias toward using all source levels. When tracing is not configured for this Core then it will be ignored without throwing exceptions.
For a review of the organizational difference between tracing and logging, see “Tracing vs Logging vs Monitoring: What’s the Difference?” by Chrissy Kidd.
Documentation 📚: Songhay.Diagnostics
Songhay.ExtensionsThe Songhay System uses imperative C# code with a view to make it more functional in an effort to control complexity and enhance maintainability.
The preference for extension methods encourages stateless, reusable routines (many of them are “pure” functions).
Notable extensions:
IConfigurationExtensions — defines shared routines based on conventions around the .NET Generic Host [📖 docs].
IConfigurationBuilderExtensions — defines shared routines for application configuration building under .NET Standard.
ILoggerExtensions — defines shared routines based on conventions around the .NET Generic Host [📖 docs].
HttpRequestMessageExtensions — defines shared routines for HTTP access under .NET Standard with a lazy-loaded HttpClient. Routines for Azure Blob Storage are included here.
HttpWebRequestExtensions — defines shared routines for HTTP access for the legacy .NET Framework.
There is support for URI templates (to be used with RestApiMetadata) in the form of extension methods, running on top of Tavis.UriTemplates.
Documentation 📚: Songhay.Extensions
Songhay.ModelsThe Core models of the Songhay System define types for MIME, XHTML, OPML, REST, the Repository, the Display Item (for WPF and other MVVM solutions), etc.
The Core models are “anemic” by design (there are very few abstract classes)—any logic would be found first in an Extension Method.
Notable models:
DisplayItemModel — defines the conventional way to display data.
MenuDisplayItemModel — defines the conventional way to display nested/grouped data.
RestApiMetadata — defines conventional REST API metadata.
Documentation 📚: Songhay.Models
Songhay.XmlThe “core” of the Core is concern for XML. The Songhay System started out as utilities around XPathDocument and grew into LINQ for XML—over XDocument.
Documentation 📚: Songhay.Xml
SonghayCore.xUnitDefines reusable class definitions for xUnit. Featured is the ProjectFileDataAttribute, allowing test data files to be loaded from a relative path.
NuGet package 📦: SonghayCore.xUnit
Documentation 📚: Songhay.Tests
SonghayCore.NewtonsoftCore reusable, opinionated Newtonsoft concerns for my C# projects.
NuGet package 📦: SonghayCore.Newtonsoft
SonghayCoregraph BT
netstandard2[.NET Standard 2.0]
net6[.NET 6.0]
1[`SonghayCore`]
2[`SonghayCore.Newtonsoft`]
net6-->1
netstandard2-->2
2-..->|optional addition|1
1-->3[`SonghayCore.xUnit`]
1-->4[`Songhay.DataAccess`]
1-->5[`Songhay.Feeds`]
1-->6[`Songhay.Publications`]
1-->7[`Songhay.Social`]