Skip to content

Contributing libraries

This page explains how to add or change a ConnectSoft shared library, such as a ConnectSoft.Extensions.* package, a UI kit or an API client. It is written for engineers who contribute to the shared library estate.

Libraries are consumed by templates and by every generated service, so a library change reaches the whole estate. Keep libraries small and focused, with good defaults that callers can override.

Library or template

UI kit and component repositories are libraries by default. Add dotnet new template metadata only when the repository intentionally generates a new starter project. See Blazor and MAUI template alignment for how Blazor and MAUI repositories are classified.

When to create or change a library

Create a library when: - the same functionality is needed in several services or templates; - it is a cross-cutting concern, such as logging, HTTP, messaging, options or metrics; - it integrates with a ConnectSoft platform.

Do not put business-specific logic in a generic library.

Change an existing library for: - fixes; - backward-compatible features; - breaking changes. A breaking change needs an ADR and a new major version (see CS-PRC-004).

New libraries are scaffolded from ConnectSoft.LibraryTemplate with dotnet new. API client libraries are scaffolded from ConnectSoft.ApiLibraryTemplate.

API and options design

  • One responsibility per library. Libraries compose; they do not grow into frameworks.
  • Good defaults, overridable through options. Configuration uses the Microsoft.Extensions.Options pattern, with options validated at start-up through an IValidateOptions<T> implementation. Each options validator has its own test class (CS-VAL-001).
  • Dependency injection. Each library exposes IServiceCollection extension methods that register it.
  • Async I/O. I/O APIs are asynchronous and accept a CancellationToken.
  • Logging. Libraries log through source-generated [LoggerMessage] methods (CS-LOG-002).
  • Clear errors. Exceptions name the setting or argument at fault and how to fix it.
  • Object mapping. Libraries that map objects depend on ConnectSoft.Extensions.ObjectMapping, not on a mapper package directly (ADR-0106).

Compatibility and deprecation

  • Minor and patch versions are backward compatible.
  • Before removing a public API, mark it [Obsolete] with a message that names the replacement, for at least one minor version.
  • State every breaking change in the pull request description (CS-PRC-005).
  • Target the frameworks set by ADR-0102. Upgrade packages in the order of Upgrade order and promotion levels.

Tests

  • Unit tests follow the testing standard: MSTest, the coverage target of 80% with the ratchet, and one test class per validator.
  • Tests that call a live external system are in the "Integration Tests" category, so that CI can exclude them.

Publishing and consumption

  • The pipeline packs and pushes the package to the ConnectSoft Azure Artifacts feed on every build of the default branch (see Versioning and release).
  • Consumers reference libraries through central package management (Directory.Packages.props). Templates pin library versions.
  • Update dependent templates and services through the upgrade order. Breaking changes are coordinated across the templates that consume the library.