A collection of reusable utility libraries for .NET, published as individual NuGet packages. Each package targets a specific concern — from core extensions and domain primitives to data access, dependency injection, MediatR pipelines, ASP.NET Core helpers, and WPF utilities — so you can pull in only what you need.
- .NET 9 SDK (for
net9.0targets) - .NET 8 SDK (for
net8.0targets) - .NET Standard 2.0 / 2.1 targets are compatible with .NET Framework 4.6.1+ and .NET Core 2.0+
Install any package via the NuGet Package Manager, the .NET CLI, or by editing your project file.
.NET CLI
dotnet add package SharedCode.Core
dotnet add package SharedCode.Data
dotnet add package SharedCode.Data.CosmosDb
dotnet add package SharedCode.Data.EntityFramework
dotnet add package SharedCode.DependencyInjection
dotnet add package SharedCode.MediatR
dotnet add package SharedCode.Web
dotnet add package SharedCode.Windows.WPFPackage Manager Console
Install-Package SharedCode.Core
Install-Package SharedCode.Data
Install-Package SharedCode.Data.CosmosDb
Install-Package SharedCode.Data.EntityFramework
Install-Package SharedCode.DependencyInjection
Install-Package SharedCode.MediatR
Install-Package SharedCode.Web
Install-Package SharedCode.Windows.WPFCore utilities and domain primitives that are shared across all other packages. Targets
netstandard2.0, netstandard2.1, net8.0, and net9.0.
Highlights
- Extension methods —
DateTime,DateTimeOffset,string,int,Enum, collections,Type,IEnumerable, reflection, and more - Specification pattern — strongly typed
Specification<T>/Specification<T, TResult>with a fluent query builder (filter, ordering, paging, includes) - Domain primitives —
ValueObject,BaseException, result types (IResult,IErrorResult,ValidationErrorResult) - Security —
Hasherutility supporting multiple hash algorithms - Text —
StringExtensions,StringBuilderExtensions, masking helpers - Calendar — business-day arithmetic,
DateTimeFormat,DayOfWeekExtensions - Reactive — built on
System.ReactiveandSystem.Interactive - Threading — async-friendly utilities
Quick Start
// Add business days
var nextBusinessDay = DateTime.Today.AddBusinessDays(3);
// Specification pattern
public sealed class ActiveUsersSpec : Specification<User>
{
public ActiveUsersSpec() =>
this.Query.Where(u => u.IsActive).OrderBy(u => u.LastName);
}Framework-agnostic data access abstractions. Targets netstandard2.0, netstandard2.1,
net8.0, and net9.0.
Highlights
IQueryRepository<T>/ICommandRepository<T>contractsQueryRepository<T>— default generic / in-memory implementationIQueryResult<T>with paging support viaPagingDescriptorandPageBoundryAddOrUpdatedescriptor patternDataReaderExtensions,DynamicDataRecord, and ODataDataServiceQueryExtensions
Quick Start
public class UserService
{
private readonly IQueryRepository<User> repository;
public UserService(IQueryRepository<User> repository) =>
this.repository = repository;
public async Task<IQueryResult<User>> GetActiveUsersAsync(CancellationToken ct) =>
await this.repository.ListAsync(new ActiveUsersSpec(), ct);
}Azure Cosmos DB integration built on top of the official
Microsoft.Azure.Cosmos SDK.
Targets net8.0 and net9.0.
Highlights
- Cosmos DB query helpers and logger extensions
Query<T>helper for building Cosmos DB LINQ queries
Entity Framework Core integration. Targets net8.0 and net9.0.
Highlights
AuditableDbContext— automatically stampsCreatedAt/ModifiedAtonIAuditableEntityEfRepository<T>— EF Core implementation ofIQueryRepository<T>andICommandRepository<T>Entitybase class andIAuditableEntity/IAuditedEntityinterfaces- Specification evaluator wired directly into EF Core queries
IDataService/DataServicefor unit-of-work style operations
Quick Start
// Register with resilient SQL Server connection
services.AddDbContext<AppDbContext>(options =>
options.UseSqlServer(
connectionString,
sqlOptions => sqlOptions.EnableRetryOnFailure(
maxRetryCount: 10,
maxRetryDelay: TimeSpan.FromSeconds(30),
errorNumbersToAdd: null)));Assembly scanning and automatic service registration. Targets netstandard2.0,
netstandard2.1, net8.0, and net9.0.
Highlights
IDependencyRegister— implement on any class to self-register servicesDependencyLoader— scans assemblies and invokes allIDependencyRegisterimplementationsCatalogSelector/TypeSourceSelectorfor fine-grained assembly and type filtering
Quick Start
// In Startup.cs / Program.cs
services.LoadDependencies(typeof(Program).Assembly);
// In any library
public class MyServiceRegistrar : IDependencyRegister
{
public void Register(IServiceCollection services) =>
services.AddScoped<IMyService, MyService>();
}MediatR pipeline abstractions. Targets net8.0 and
net9.0.
Highlights
ICommand/ICommand<TResponse>— strongly typed command markersICommandHandler/ICommandHandler<TCommand, TResponse>— handler contractsIQuery<TResponse>/IQueryHandler<TQuery, TResponse>— query/response contracts- Extension method for registering MediatR from an assembly
Quick Start
// Define a command
public sealed record CreateUserCommand(string Name) : ICommand<Guid>;
// Implement a handler
public sealed class CreateUserCommandHandler : ICommandHandler<CreateUserCommand, Guid>
{
public async Task<Guid> Handle(CreateUserCommand request, CancellationToken ct)
{
// create user ...
return newUser.Id;
}
}
// Register in Program.cs
services.AddSharedCodeMediatR(typeof(Program).Assembly);ASP.NET Core helpers. Targets net9.0.
Highlights
BaseController— abstract controller base that exposes anIHttpClientFactory- Service collection extensions for resilient HTTP clients (Polly retry/wait)
- Health check registration helpers
Quick Start
[ApiController]
[Route("api/[controller]")]
public class UsersController : BaseController
{
public UsersController(IHttpClientFactory httpClientFactory)
: base(httpClientFactory) { }
}WPF helpers targeting net9.0-windows10.0.22621.0.
Highlights
BindableBase— base class implementingINotifyPropertyChanged- Value converters —
BooleanToVisibilityConverter,StringToVisibilityConverter,NumberToStringConverter PasswordHelper— attached property for bindingPasswordBox.PasswordMediator— simple in-process message broker for loosely coupled view-modelsModalTemplateAttribute— data-template helper for modal view-models
Note: The WPF community has excellent implementations of commands and more in the CommunityToolkit.Mvvm package. That package is referenced as a dependency and its commands are the recommended approach.
# Clone the repository
git clone https://github.com/improvgroup/sharedcode.git
cd sharedcode
# Restore and build
dotnet build SharedCode.sln
# Run all tests
dotnet test SharedCode.slnThe solution targets .NET 9 for the library projects. The WPF project additionally requires Windows 10 SDK version 10.0.19041.0 or later.
Contributions are welcome! Please follow these steps:
- Fork the repository and create a feature branch.
- Make your changes, ensuring all existing tests pass (
dotnet test SharedCode.sln). - Add or update tests as appropriate.
- Open a pull request against the
mainbranch.
Please read the Code of Conduct and Security Policy before contributing.
This project is licensed under the MIT License.
Copyright © 2025 improvGroup, LLC and contributors.