Skip to content

High-performance capability composition for .NET

Cocoar.Capabilities

A high-performance, low-allocation capability composition library for .NET that implements the Capability Composition pattern for building extensible, type-safe systems.

NuGetLicense.NETDownloads

Installation

dotnet add package Cocoar.Capabilities

Quick Start

usingCocoar.Capabilities;// Create a scope and compose capabilities onto a subjectvarscope=newCapabilityScope();scope.Compose("user-service").Add(newLoggingCapability{Level=LogLevel.Debug}).Add(newRetryCapability{MaxAttempts=3}).Build();// Query the compositionvarcomposition=scope.Compositions.GetRequired<string>("user-service");varlogging=composition.GetFirstOrDefault<LoggingCapability>();Console.WriteLine(composition.Has<LoggingCapability>());// True

Documentation

Full documentation with guides, API reference, and examples:

docs.cocoar.dev/capabilities

Key Concepts

TypeRole
CapabilityScopeContainer that manages composers and compositions
ComposerFluent builder for attaching capabilities to a subject
ICompositionImmutable, thread-safe result of a composition
IPrimaryCapabilityMarker interface for the "identity" capability
CapabilityScope<TOwner>Strongly-typed scope with immutable owner

Contributing & Versioning

  • SemVer (additive MINOR, breaking MAJOR)
  • PRs & issues welcome
  • Licensed under Apache License 2.0 (explicit patent grant & attribution via NOTICE)

License & Trademark

This project is licensed under the Apache License, Version 2.0. See NOTICE for attribution.

"Cocoar" and related marks are trademarks of COCOAR e.U. Use of the name in forks or derivatives should preserve attribution and avoid implying official endorsement. See TRADEMARKS for permitted and restricted uses.

Releases

Packages

Contributors

Languages