CasCap.Common.AI
AI and LLM integration abstractions for OpenAI, Ollama, and Model Context Protocol.
Ask AI about CasCap.Common.AI
Powered by Claude Β· Grounded in docs
I know everything about CasCap.Common.AI. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
CasCap.Common
A .NET class library repository containing 14 NuGet packages with helper functions, extensions, utilities, AI integration, and abstract classes for .NET applications.
Libraries
| Library | Description | Targets | Packable |
|---|---|---|---|
| CasCap.Common.Abstractions | Core interface definitions (IAppConfig, IFeature<T>, ILocalCache, IEventSink<T>, INotifier) | netstandard2.0; net8.0; net9.0; net10.0 | β |
| CasCap.Common.AI | AI agent framework β multi-provider agent creation, session management, MCP tool/prompt resolution, chat history compaction | net10.0 | β |
| CasCap.Common.Caching | Distributed caching (cache-aside pattern) with Memory/Disk local cache, Redis remote cache, and optional distributed locking | netstandard2.0; net8.0; net9.0; net10.0 | β |
| CasCap.Common.Configuration | Configuration bootstrapping β standard IConfiguration pipeline, Azure Key Vault, and validated IOptions<T> binding | netstandard2.0; net8.0; net9.0; net10.0 | β |
| CasCap.Common.Extensions | Common extension methods and helper utilities | netstandard2.0; net8.0; net9.0; net10.0 | β |
| CasCap.Common.Extensions.Diagnostics.HealthChecks | Custom health check extensions | netstandard2.0; net8.0; net9.0; net10.0 | β |
| CasCap.Common.Logging | Static logging abstraction via ApplicationLogging | netstandard2.0; net8.0; net9.0; net10.0 | β |
| CasCap.Common.Logging.Serilog | Reusable Serilog configuration with standard enrichers, console sink, and health-check filtering | net8.0; net9.0; net10.0 | β |
| CasCap.Common.Net | HttpClientBase, BasicAuthenticationHandler, HTTP client wrappers (net8.0+ only via #if) | netstandard2.0; net8.0; net9.0; net10.0 | β |
| CasCap.Common.OpenTelemetry | Reusable OpenTelemetry configuration with standard metrics, traces, and log exporters via OTLP gRPC | net8.0; net9.0; net10.0 | β |
| CasCap.Common.Serialization.Json | System.Text.Json serialization helpers | netstandard2.0; net8.0; net9.0; net10.0 | β |
| CasCap.Common.Serialization.MessagePack | MessagePack serialization helpers | netstandard2.0; net8.0; net9.0; net10.0 | β |
| CasCap.Common.Services | FeatureFlagBgService<T> and IFeature<T> abstractions | net8.0; net9.0; net10.0 | β |
| CasCap.Common.Testing | xUnit test logging utilities | netstandard2.0; net8.0; net9.0; net10.0 | β |
Test Projects
| Project | Targets |
|---|---|
| CasCap.Common.Caching.Tests | net8.0; net9.0; net10.0 |
| CasCap.Common.Extensions.Tests | net8.0; net9.0; net10.0 |
| CasCap.Common.Net.Tests | net8.0; net9.0; net10.0 |
| CasCap.Common.Serialization.Tests | net8.0; net9.0; net10.0 |
Dependency Graph
Project reference relationships between libraries (NuGet-only dependencies omitted).
graph TD
Logging[CasCap.Common.Logging]
LoggingSerilog[CasCap.Common.Logging.Serilog]
Abstractions[CasCap.Common.Abstractions]
Extensions[CasCap.Common.Extensions]
Configuration[CasCap.Common.Configuration]
SerJson[CasCap.Common.Serialization.Json]
SerMsgPack[CasCap.Common.Serialization.MessagePack]
Net[CasCap.Common.Net]
Caching[CasCap.Common.Caching]
Services[CasCap.Common.Services]
HealthChecks[CasCap.Common.Extensions.Diagnostics.HealthChecks]
Testing[CasCap.Common.Testing]
AI[CasCap.Common.AI]
OTel[CasCap.Common.OpenTelemetry]
Extensions --> Logging
LoggingSerilog --> Logging
Configuration --> Abstractions
Configuration --> Logging
SerJson --> Extensions
SerJson --> Logging
SerMsgPack --> Logging
Net --> Abstractions
Net --> SerJson
Net --> Logging
HealthChecks --> Extensions
HealthChecks --> Logging
Testing --> Logging
Services --> Abstractions
Services --> Extensions
Caching --> Abstractions
Caching --> Extensions
Caching --> SerJson
Caching --> SerMsgPack
Caching --> Logging
AI --> Abstractions
AI --> Caching
AI --> Extensions
AI --> LoggingSerilog
OTel --> Abstractions
OTel --> LoggingSerilog
OTel --> Services
Test project relationships:
graph TD
Testing[CasCap.Common.Testing]
CachingTests[CasCap.Common.Caching.Tests] --> Caching[CasCap.Common.Caching]
CachingTests --> Testing
ExtTests[CasCap.Common.Extensions.Tests] --> Extensions[CasCap.Common.Extensions]
ExtTests --> Testing
NetTests[CasCap.Common.Net.Tests] --> Net[CasCap.Common.Net]
NetTests --> Testing
SerTests[CasCap.Common.Serialization.Tests] --> SerJson[CasCap.Common.Serialization.Json]
SerTests --> SerMsgPack[CasCap.Common.Serialization.MessagePack]
SerTests --> Testing
Prerequisites
- .NET SDK: 10.0.x stable (see
global.jsonβallowPrerelease: false) - Docker: Required for Redis in caching tests
Build and Test
# 1. Restore (required before build)
dotnet restore
# 2. Build
dotnet build --no-restore
# 3. Start Redis (required before caching tests)
docker run -d -p 6379:6379 --name cascap-redis redis
# 4. Run tests β ALWAYS use --maxcpucount:1
dotnet test --no-build --maxcpucount:1
CRITICAL: Always use
--maxcpucount:1β parallel execution causes failures due toInlineDataand RedisClearOnStartupproperty conflicts.
Expected Build Behaviour
- Build produces nullability warnings (CS8604, CS8765) β these are accepted and must not be "fixed".
- Multi-target builds take ~15β20 seconds.
Project Configuration
Key Files
| File | Purpose |
|---|---|
Directory.Build.props | C# 14.0, ImplicitUsings, Nullable: enable, IsPackable: false by default |
Directory.Packages.props | Central package version management (ManagePackageVersionsCentrally: true) |
.editorconfig | Code style rules (4-space indent, LF line endings, full formatting rules) |
global.json | SDK constraint β stable releases only |
docker-compose.yml | Redis and Redis UI (p3x-redis-ui) services |
GitVersion.yml | Semantic versioning configuration |
Suppressed Warnings
Configured in Directory.Build.props: IDE1006, IDE0079, IDE0042, CS0162, CS1574, S125, NETSDK1233, NU1901, NU1902, NU1903
CI/CD Pipeline
GitHub Actions (.github/workflows/ci.yml)
Triggers: Push (except preview/**), PRs to main, manual dispatch.
Jobs:
- lint β Reusable workflow from
f2calv/gha-workflows - versioning β GitVersion-based semantic versioning
- build β Ubuntu-latest with Redis service container; uses
f2calv/gha-dotnet-nuget@v2; test args include--maxcpucount:1 - release β GitHub release (main branch only, when tag doesn't already exist)
Making Changes
Adding Code
- Place code in the correct project by functionality
- Follow
.editorconfigstyle rules - Add XML documentation to all public API surface
- Add tests in the corresponding
.Testsproject - Validate:
dotnet build --no-restoreβ 0 errors - Validate:
dotnet test --no-build --maxcpucount:1β all pass
Adding Dependencies
-
Add version to
Directory.Packages.props -
Reference in
.csprojwithout a version attribute:<PackageReference Include="PackageName" /> -
Run
dotnet restore
Creating New Projects
- Library projects inherit
Directory.Build.propsautomatically - Set
<IsPackable>true</IsPackable>explicitly only for NuGet packages - Test projects must not be packable (default) and must target
net8.0;net9.0;net10.0
Validation Checklist
-
dotnet restoresucceeds -
dotnet build --no-restorecompletes with 0 errors - Redis is running (if testing caching)
-
dotnet test --no-build --maxcpucount:1passes all tests - Public API has XML documentation
- Properties separated by blank lines
-
ServiceProviderinstances are disposed in tests - No shared mutable static state in test helpers
Contributing
- Fork the repository and create a feature branch
- Follow all conventions documented above
- Run the full validation checklist before submitting a PR
- PRs target the
mainbranch and require CI to pass - Versioning is automated via GitVersion β do not manually edit version numbers
- When using Copilot to implement code quality or legibility improvements, update the copilot-instructions.md to capture any new conventions so they are applied consistently in future sessions
