Skip to content

PowerCSharp v2.0.2 — Features Framework & Cache Family

Latest

Choose a tag to compare

@marioarce marioarce released this 22 Jun 22:54

This is the v2.0.x line's headline release. It introduces the brand-new PowerCSharp Features architecture — a production-grade, modular, flag-driven system that lets developers compose, toggle, and ship capabilities independently, without coupling package adoption to application deployment.


What Is the Features Framework?

The Features system is a first-class extension point for the PowerCSharp ecosystem. It defines two tiers of capability:

Tier Name Shipped in Gate
Group 1 Built-in Features PowerCSharp.BuiltInFeatures Runtime flag only
Group 2 Pluggable Features Standalone packages (PowerCSharp.Feature.*) Package reference + runtime flag

Both tiers are self-contained, independently versioned, and share a common contract surface (PowerCSharp.Features.Abstractions) that any developer or company can implement to build their own feature.


📦 New Packages in v2.0.x

Features Framework Trio — v1.0.1

Package Role
PowerCSharp.Features.Abstractions Contracts only: IFeatureModule, IFeatureFlagProvider, FeatureOptionsBase, FeatureDescriptor. Zero third-party deps. netstandard2.0 + net8.0.
PowerCSharp.Features The engine: module auto-discovery, composite flag resolver, DI orchestration, feature registry, opt-in diagnostics endpoint.
PowerCSharp.BuiltInFeatures Bundle of runtime-toggled ASP.NET Core capabilities. First built-in: CORS.

Cache Feature Family — v1.3.1

Package Role
PowerCSharp.Feature.Cache.Abstractions Framework-agnostic cache contracts (ICacheService, IDiskCacheService, CacheResult<T>, CacheMetadata). NoOp safe-off floor. netstandard2.0 + net8.0.
PowerCSharp.Feature.Cache Cache feature module, CacheFeatureOptions, AddCacheFeature().
PowerCSharp.Feature.Cache.BitFaster High-performance in-memory LRU cache backed by BitFaster.Caching. Stampede protection.
PowerCSharp.Feature.Cache.Disk Disk-backed LRU with atomic writes, cross-process file locks, and background cleanup.

⚡ Quick Start

Features Framework

dotnet add package PowerCSharp.Features.Abstractions
dotnet add package PowerCSharp.Features
dotnet add package PowerCSharp.BuiltInFeatures
// Program.cs
builder.Services.AddPowerFeatures(builder.Configuration, options =>
{
    options.AddBuiltInFeatures();          // CORS and other built-ins
    options.ScanAssemblies(typeof(CacheFeatureModule).Assembly);
    options.Override("Cache", true);       // code-level override
    options.EnableDiagnosticsEndpoint();   // GET /power-features
});

var app = builder.Build();
app.UsePowerFeatures();
// appsettings.json
{
  "PowerFeatures": {
    "Cors":  { "Enabled": true, "AllowedOrigins": ["https://example.com"] },
    "Cache": { "Enabled": true, "Provider": "BitFaster", "Capacity": 5000 }
  }
}

Cache Feature

dotnet add package PowerCSharp.Feature.Cache
dotnet add package PowerCSharp.Feature.Cache.BitFaster  # or .Disk
var cache = app.Services.GetRequiredService<ICacheService>();

var result = await cache.GetAsync<MyData>("key");
if (!result.Hit)
{
    var data = await FetchFromSourceAsync();
    await cache.SetAsync("key", data, TimeSpan.FromMinutes(10));
}

🏗️ Architecture Highlights

Flag Resolution Chain (highest precedence first)

Code override  →  Custom IFeatureFlagProvider  →  Environment variables  →  appsettings  →  Feature default

Environment variable convention:

POWERFEATURES__CACHE__ENABLED=true
POWERFEATURES__CORS__ENABLED=false

Two-Layer Gating (Pluggable Features)

Scenario Result
No package reference Feature doesn't exist — zero code, zero deps
Package referenced, flag off NoOp registered — dependents always resolve safely
Package referenced, flag on Active provider registered — full functionality

Diagnostics Endpoint

When enabled, GET /power-features returns the live feature matrix:

[
  { "Key": "Cache", "Tier": "Pluggable", "Enabled": true,  "Source": "Configuration", "Version": "1.3.1" },
  { "Key": "Cors",  "Tier": "BuiltIn",   "Enabled": true,  "Source": "Configuration", "Version": "1.0.1" }
]

🔧 Also in v2.0.x

  • EditorConfig — comprehensive coding standards (member ordering, braces, nullable) applied across the full codebase
  • DirectoryExtensionsTrySafeDelete and safe directory-manipulation helpers
  • CI/CDupdate-version workflow now supports independent version bumping per package family (core / features / cache) via workflow_dispatch
  • Code quality — all Console.WriteLine debug artifacts removed from production library code; startup logging via ILogger in UsePowerFeatures

📚 Documentation

Document Description
Features Architecture System design, two tiers, dependency topology
Features Engine API AddPowerFeatures, UsePowerFeatures, PowerFeaturesOptions, registry
BuiltInFeatures API CORS reference, replace-a-builtin pattern, roadmap
Cache Family API Full Cache family reference, ICacheService, providers
Authoring Guide Step-by-step guide to building a new Feature
Flag Reference Flag schema, provider precedence, environment conventions

🚀 Installation — Full Suite

# Core libraries (v2.0.2)
dotnet add package PowerCSharp.Core
dotnet add package PowerCSharp.Extensions
dotnet add package PowerCSharp.Extensions.AspNetCore
dotnet add package PowerCSharp.Utilities
dotnet add package PowerCSharp.Helpers

# Features framework (v1.0.1)
dotnet add package PowerCSharp.Features.Abstractions
dotnet add package PowerCSharp.Features
dotnet add package PowerCSharp.BuiltInFeatures

# Cache feature (v1.3.1) — pick a provider
dotnet add package PowerCSharp.Feature.Cache
dotnet add package PowerCSharp.Feature.Cache.BitFaster   # in-memory LRU
dotnet add package PowerCSharp.Feature.Cache.Disk        # disk-backed LRU

🤝 Build Your Own Feature

The contract is open. Any developer or company can:

  1. Reference PowerCSharp.Features.Abstractions
  2. Implement IFeatureModule
  3. Optionally implement IFeatureFlagProvider for custom flag sources (Azure App Config, AWS SSM, database, etc.)
  4. Register via options.ScanAssemblies(...) or options.AddModule(...)

The engine handles discovery, flag resolution, DI orchestration, startup logging, and diagnostics — your module focuses only on its own capability.


📊 Package Statistics

NuGet
NuGet
NuGet
NuGet


🔮 Roadmap — v2.1.x

  • PowerCSharp.Feature.Cache.Memory — native IMemoryCache provider
  • Built-in Features: CorrelationId, SecurityHeaders, ExceptionHandling
  • PowerCSharp.Feature.Observability — OpenTelemetry integration
  • Hotfix branch CI/CD support

🙏 Thank You

Built by Mario Arce — Software Architect with 20+ years of enterprise C# experience. This release is the foundation for a modular, composable C# ecosystem that grows with your project, not against it.

Star the repo — it helps more developers discover the library.
🐛 Report Issues
💬 GitHub Discussions


PowerCSharp v2.0.2 · PowerCSharp.Features v1.0.1 · PowerCSharp.Feature.Cache v1.3.1
#PowerCSharp #CSharp #DotNet #OpenSource #NuGet #FeatureFlags #Architecture