ANcpLua.NET.Sdk.Test
1.4.1
See the version list below for details.
dotnet add package ANcpLua.NET.Sdk.Test --version 1.4.1
NuGet\Install-Package ANcpLua.NET.Sdk.Test -Version 1.4.1
<PackageReference Include="ANcpLua.NET.Sdk.Test" Version="1.4.1" />
<PackageVersion Include="ANcpLua.NET.Sdk.Test" Version="1.4.1" />
<PackageReference Include="ANcpLua.NET.Sdk.Test" />
paket add ANcpLua.NET.Sdk.Test --version 1.4.1
#r "nuget: ANcpLua.NET.Sdk.Test, 1.4.1"
#:package ANcpLua.NET.Sdk.Test@1.4.1
#addin nuget:?package=ANcpLua.NET.Sdk.Test&version=1.4.1
#tool nuget:?package=ANcpLua.NET.Sdk.Test&version=1.4.1
ANcpLua.NET.Sdk
MSBuild SDK with opinionated defaults for .NET projects. Inspired by Meziantou.NET.Sdk.
SDKs
| SDK | Base SDK | Use For |
|---|---|---|
ANcpLua.NET.Sdk |
Microsoft.NET.Sdk |
Libraries, Console Apps, Workers, Unit Tests |
ANcpLua.NET.Sdk.Web |
Microsoft.NET.Sdk.Web |
Web APIs, ASP.NET Core, Integration Tests |
Installation
Add a global.json to your repo root:
{
"msbuild-sdks": {
"ANcpLua.NET.Sdk": "*",
"ANcpLua.NET.Sdk.Web": "*"
}
}
Then replace your SDK reference:
<Project Sdk="ANcpLua.NET.Sdk"></Project>
For Web projects:
<Project Sdk="ANcpLua.NET.Sdk.Web"></Project>
Working Features
Banned API Analyzer (RS0030)
Enforces best practices via BannedSymbols.txt:
| Banned | Use Instead |
|---|---|
DateTime.Now/UtcNow |
TimeProvider.System.GetUtcNow() |
DateTimeOffset.Now/UtcNow |
TimeProvider.System.GetUtcNow() |
ArgumentNullException.ThrowIfNull |
Native .NET 6+ API (polyfilled) |
Enumerable.Any(predicate) |
List<T>.Exists() |
Enumerable.FirstOrDefault(predicate) |
List<T>.Find() |
InvariantCulture comparisons |
Ordinal |
System.Tuple |
ValueTuple |
Math.Round (no rounding mode) |
Overload with MidpointRounding |
| Local time file APIs | UTC variants |
| Newtonsoft.Json | System.Text.Json |
ANcpLua.Analyzers (Bundled)
| Rule | Severity | Description |
|---|---|---|
| AL0001 | Error | Prohibit reassignment of primary constructor params |
| AL0003 | Error | Don't divide by constant zero |
| AL0011 | Warning | Avoid lock on non-Lock types (.NET 9+) |
| AL0012 | Warning | Deprecated OTel semantic convention attribute |
| AL0013 | Info | Missing telemetry schema URL |
See ANcpLua.Analyzers for all 16 rules.
Extensions (Auto-Enabled by Default)
| Property | Description | Default |
|---|---|---|
GenerateClaudeMd |
Auto-generates CLAUDE.md linking to repo root |
true |
InjectSharedThrow |
Injects Throw.IfNull() guard clause helper |
true |
IncludeDefaultBannedSymbols |
Include BannedSymbols.txt | true |
BanNewtonsoftJsonSymbols |
Ban Newtonsoft.Json direct usage | true |
Extensions (Opt-in)
| Property | Description | Default |
|---|---|---|
InjectStringOrdinalComparer |
Injects internal StringOrdinalComparer |
false |
InjectFakeLogger |
Injects FakeLoggerExtensions (requires FakeLogCollector) |
false |
InjectSourceGenHelpers |
Roslyn source generator utilities (details) | false |
SourceGen Helpers include: EquatableArray<T>, DiagnosticInfo, DiagnosticsExtensions, SymbolExtensions, SyntaxExtensions, SemanticModelExtensions, CompilationExtensions, SyntaxValueProvider helpers, EnumerableExtensions, FileExtensions, LocationInfo, EquatableMessageArgs
For analyzers, CLI tools, or test projects, use ANcpLua.Roslyn.Utilities NuGet package instead.
Analyzer Test Fixtures (Auto-Injected)
Test projects with "Analyzer" in their name automatically receive:
| Package | Purpose |
|---|---|
Microsoft.CodeAnalysis.CSharp.Analyzer.Testing |
Analyzer test infrastructure |
Microsoft.CodeAnalysis.CSharp.CodeFix.Testing |
Code fix test infrastructure |
Basic.Reference.Assemblies.Net100 |
.NET 10 reference assemblies |
Basic.Reference.Assemblies.NetStandard20 |
NetStandard 2.0 references |
Base classes injected into ANcpLua.Testing.Analyzers namespace:
// Analyzer tests
public class MyAnalyzerTests : AnalyzerTest<MyAnalyzer> {
[Fact]
public async Task Test() => await VerifyAsync("source code...");
}
// Code fix tests
public class MyCodeFixTests : CodeFixTest<MyAnalyzer, MyCodeFix> {
[Fact]
public async Task Test() => await VerifyAsync("source", "fixed");
}
// Code fix with EditorConfig
public class MyConfigTests : CodeFixTestWithEditorConfig<MyAnalyzer, MyCodeFix> {
[Fact]
public async Task Test() => await VerifyAsync(
source, fixed,
editorConfig: new() { ["my_option"] = "value" });
}
Opt-out: <InjectAnalyzerTestFixtures>false</InjectAnalyzerTestFixtures>
Polyfills (Opt-in for Legacy TFMs)
| Property | Description | Default |
|---|---|---|
InjectLockPolyfill |
Injects System.Threading.Lock (net8.0 backport) |
false |
InjectTimeProviderPolyfill |
Injects System.TimeProvider |
false |
InjectIndexRangeOnLegacy |
Injects Index and Range types |
false |
InjectIsExternalInitOnLegacy |
Injects IsExternalInit (for records) |
false |
InjectTrimAttributesOnLegacy |
Injects trimming attributes (e.g. DynamicallyAccessedMembers) |
false |
InjectNullabilityAttributesOnLegacy |
Injects nullability attributes (e.g. AllowNull) |
false |
InjectRequiredMemberOnLegacy |
Injects RequiredMemberAttribute |
false |
InjectCompilerFeatureRequiredOnLegacy |
Injects CompilerFeatureRequiredAttribute |
false |
InjectCallerAttributesOnLegacy |
Injects CallerArgumentExpressionAttribute |
false |
InjectUnreachableExceptionOnLegacy |
Injects UnreachableException |
false |
InjectExperimentalAttributeOnLegacy |
Injects ExperimentalAttribute |
false |
InjectParamCollectionOnLegacy |
Injects ParamCollectionAttribute |
false |
InjectStackTraceHiddenOnLegacy |
Injects StackTraceHiddenAttribute |
false |
Configuration
| Property | Default | Description |
|---|---|---|
GenerateClaudeMd |
true |
Generate CLAUDE.md for AI assistants |
InjectSharedThrow |
true |
Inject Throw.IfNull() guard clauses |
IncludeDefaultBannedSymbols |
true |
Include BannedSymbols.txt |
BanNewtonsoftJsonSymbols |
true |
Ban Newtonsoft.Json direct usage |
EnableDefaultTestSettings |
true |
Auto-configure test runner |
EnableCodeCoverage |
true (CI) |
Enable coverage |
Web Service Defaults (Auto-Registered for Web Projects)
When using Microsoft.NET.Sdk.Web, the SDK automatically adds Aspire 13.0-compatible service defaults:
| Feature | Description |
|---|---|
| OpenTelemetry | Logging, Metrics (ASP.NET, HTTP, Runtime), Tracing with OTLP export |
| Health Checks | /health (readiness) and /alive (liveness) endpoints |
| Service Discovery | Microsoft.Extensions.ServiceDiscovery enabled |
| HTTP Resilience | Standard resilience handlers with retries and circuit breakers |
| DevLogs | Frontend console log bridge for unified debugging (Development only) |
Opt-out: <AutoRegisterServiceDefaults>false</AutoRegisterServiceDefaults>
DevLogs - Frontend Console Bridge
Captures browser console.log/warn/error and sends to server logs. Enabled by default in Development.
Add to your HTML (only served in Development):
<script src="/dev-logs.js"></script>
All frontend logs appear in server output with [BROWSER] prefix:
info: DevLogEntry[0] [BROWSER] User clicked button
error: DevLogEntry[0] [BROWSER] Failed to fetch data
Configuration:
builder.UseANcpSdkConventions(options =>
{
options.DevLogs.Enabled = true; // Default: true
options.DevLogs.RoutePattern = "/api/dev-logs"; // Default
options.DevLogs.EnableInProduction = false; // Default: false
});
Why this matters: AI agents can see frontend and backend logs in one place without using browser MCP (which burns tokens and is slow).
Repository Requirements
This SDK enforces the following repository-level configurations:
Directory.Packages.props (Required)
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
</PropertyGroup>
Directory.Build.props (Recommended)
<PropertyGroup>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition="'$(CI)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>
Note: LangVersion and Nullable are SDK-owned properties. Place them in Directory.Build.props, NOT in individual csproj files.
Running Tests
export CI=true
export NUGET_DIRECTORY="$(pwd)/artifacts"
dotnet test --project tests/ANcpLua.Sdk.Tests/ANcpLua.Sdk.Tests.csproj
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.6.2 | 29 | 1/10/2026 |
| 1.6.1 | 33 | 1/10/2026 |
| 1.6.0 | 35 | 1/9/2026 |
| 1.5.1 | 61 | 1/8/2026 |
| 1.5.0 | 87 | 1/2/2026 |
| 1.4.2 | 79 | 1/1/2026 |
| 1.4.1 | 78 | 1/1/2026 |
| 1.4.0 | 78 | 1/1/2026 |
| 1.3.31 | 29 | 1/9/2026 |
| 1.3.30 | 33 | 1/9/2026 |
| 1.3.29 | 33 | 1/9/2026 |
| 1.3.28 | 38 | 1/9/2026 |
| 1.3.27 | 37 | 1/9/2026 |
| 1.3.26 | 36 | 1/9/2026 |
| 1.3.25 | 38 | 1/9/2026 |
| 1.3.24 | 32 | 1/9/2026 |
| 1.3.23 | 74 | 1/6/2026 |
| 1.3.22 | 78 | 1/6/2026 |
| 1.3.20 | 79 | 1/2/2026 |
| 1.3.19 | 83 | 1/2/2026 |
| 1.3.18 | 84 | 1/1/2026 |
| 1.3.17 | 80 | 1/1/2026 |
| 1.3.16 | 81 | 12/31/2025 |
| 1.3.15 | 80 | 12/31/2025 |
| 1.3.14 | 78 | 12/31/2025 |
| 1.3.13 | 79 | 12/31/2025 |
| 1.3.10 | 77 | 12/31/2025 |
| 1.3.9 | 79 | 12/31/2025 |
| 1.3.8 | 83 | 12/30/2025 |
| 1.3.7 | 80 | 12/30/2025 |
| 1.3.6 | 83 | 12/30/2025 |
| 1.3.5 | 80 | 12/30/2025 |
| 1.3.4 | 85 | 12/30/2025 |
| 1.3.3 | 81 | 12/30/2025 |
| 1.3.2 | 86 | 12/30/2025 |
| 1.3.1 | 76 | 12/30/2025 |
| 1.3.0 | 82 | 12/30/2025 |
| 1.2.4 | 90 | 12/29/2025 |
| 1.2.3 | 87 | 12/29/2025 |
| 1.2.2 | 93 | 12/29/2025 |
| 1.2.1 | 179 | 12/25/2025 |
| 1.2.0 | 173 | 12/24/2025 |
| 1.1.8 | 265 | 12/16/2025 |
| 1.1.7 | 260 | 12/16/2025 |