Skip to content

ANcpLua/ANcpLua.NET.Sdk

Repository files navigation

NuGet .NET 10 License

ANcpLua.NET.Sdk

Opinionated MSBuild SDK for .NET projects.

Quick Start

Add to global.json (check NuGet for latest version):

{
  "msbuild-sdks": {
    "ANcpLua.NET.Sdk": "1.3.31"
  }
}

Tip: Use Dependabot or Renovate to auto-update SDK versions.

<!-- Library/Console/Worker -->
<Project Sdk="ANcpLua.NET.Sdk"></Project>

<!-- Web API -->
<Project Sdk="ANcpLua.NET.Sdk.Web"></Project>

What You Get

Base SDK:

  • Banned API enforcement (DateTime.NowTimeProvider, etc.)
  • Custom analyzers via ANcpLua.Analyzers
  • Throw.IfNull() guard clauses
  • CLAUDE.md generation for AI assistants

Web SDK adds:

  • OpenTelemetry (logging, metrics, tracing with OTLP)
  • Auto-instrumentation for GenAI (OpenAI, Anthropic, Ollama) and Database calls
  • Health endpoints (/health, /alive)
  • HTTP resilience (retries, circuit breakers)
  • DevLogs (browser console → server logs)

Opt-in Features

<PropertyGroup>
  <!-- Roslyn source generator utilities -->
  <InjectSourceGenHelpers>true</InjectSourceGenHelpers>

  <!-- FakeLogger test extensions -->
  <InjectFakeLogger>true</InjectFakeLogger>

  <!-- Legacy TFM polyfills -->
  <InjectLockPolyfill>true</InjectLockPolyfill>
  <InjectTimeProviderPolyfill>true</InjectTimeProviderPolyfill>
</PropertyGroup>

[OTel] Attribute (Web SDK)

Mark properties with OpenTelemetry semantic convention names for automatic tag generation:

using ANcpSdk.AspNetCore.ServiceDefaults.Instrumentation;

public record ChatRequest(
    [OTel("gen_ai.request.model")] string Model,
    [OTel("gen_ai.request.max_tokens")] int? MaxTokens);

// Generated extension method:
activity.SetTagsFromChatRequest(request);

Opt-out

<PropertyGroup>
  <!-- Disable service defaults for Web SDK -->
  <AutoRegisterServiceDefaults>false</AutoRegisterServiceDefaults>

  <!-- Disable specific features -->
  <GenerateClaudeMd>false</GenerateClaudeMd>
  <InjectSharedThrow>false</InjectSharedThrow>
  <IncludeDefaultBannedSymbols>false</IncludeDefaultBannedSymbols>
</PropertyGroup>

DevLogs (Web SDK)

Captures browser console and sends to server logs. Add to your HTML:

<script src="/dev-logs.js"></script>

All frontend logs appear in server output with [BROWSER] prefix.

Requirements

Central Package Management enabled in Directory.Packages.props:

<PropertyGroup>
  <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>

Documentation

Full reference: https://ancplua.mintlify.app/sdk/overview

Related


Initial architecture inspired by Meziantou.NET.Sdk.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •