ANcpLua.NET.Sdk 1.2.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package ANcpLua.NET.Sdk --version 1.2.4
                    
NuGet\Install-Package ANcpLua.NET.Sdk -Version 1.2.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ANcpLua.NET.Sdk" Version="1.2.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ANcpLua.NET.Sdk" Version="1.2.4" />
                    
Directory.Packages.props
<PackageReference Include="ANcpLua.NET.Sdk" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ANcpLua.NET.Sdk --version 1.2.4
                    
#r "nuget: ANcpLua.NET.Sdk, 1.2.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ANcpLua.NET.Sdk@1.2.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ANcpLua.NET.Sdk&version=1.2.4
                    
Install as a Cake Addin
#tool nuget:?package=ANcpLua.NET.Sdk&version=1.2.4
                    
Install as a Cake Tool

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

Replace your SDK reference:


<Project Sdk="ANcpLua.NET.Sdk/1.2.0"></Project>


<Project Sdk="ANcpLua.NET.Sdk.Web/1.2.0"></Project>

Or use global.json for centralized version management:

{
  "msbuild-sdks": {
    "ANcpLua.NET.Sdk": "1.2.0",
    "ANcpLua.NET.Sdk.Web": "1.2.0"
  }
}

Then reference without version:


<Project Sdk="ANcpLua.NET.Sdk"></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 13 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

<details> <summary><b>SourceGen Helpers</b> - what's included</summary>

  • EquatableArray<T> - IEquatable wrapper for ImmutableArray (incremental generator caching)
  • DiagnosticInfo / DiagnosticsExtensions - Simplified diagnostic creation
  • SymbolExtensions - HasAttribute, GetAttribute, IsOrInheritsFrom, ImplementsInterface, GetMethod, GetProperty
  • SyntaxExtensions - GetMethodName, GetIdentifierName, HasModifier
  • SemanticModelExtensions - IsConstant, AllConstant, GetConstantValueOrDefault
  • CompilationExtensions - IsCSharp9OrGreater, IsCSharp10OrGreater, IsCSharp11OrGreater
  • SyntaxValueProvider helpers - ForClassesWithAttribute, ForMethodsWithAttribute
  • EnumerableExtensions - SelectManyOrEmpty, OrEmpty, ToImmutableArrayOrEmpty, HasDuplicates
  • FileExtensions - WriteIfChangedAsync (avoid unnecessary file writes)
  • LocationInfo, EquatableMessageArgs - Equatable records for caching

Note: For analyzers, CLI tools, or test projects, use ANcpLua.Roslyn.Utilities NuGet package instead. The embedded source approach is specifically for source generators which cannot easily reference NuGet packages.

</details>

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
InjectThrowPolyfillsOnLegacy Injects C# 14 ThrowPolyfills (extension members) false

C# 14 Extension Member Polyfills

Modern throw helpers using C# 14 extension(Type) syntax. Available on all targets:

// .NET 6+ style APIs - work everywhere!
ArgumentNullException.ThrowIfNull(myArg);
ArgumentException.ThrowIfNullOrEmpty(myString);
ArgumentException.ThrowIfNullOrWhiteSpace(myString);
ArgumentOutOfRangeException.ThrowIfNegative(count);
ArgumentOutOfRangeException.ThrowIfZero(count);
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(count);
ArgumentOutOfRangeException.ThrowIfGreaterThan(value, max);
ArgumentOutOfRangeException.ThrowIfLessThan(value, min);
ObjectDisposedException.ThrowIf(isDisposed, this);

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

Opt-out: <AutoRegisterServiceDefaults>false</AutoRegisterServiceDefaults>

Running Tests Correctly

The test suite simulates an environment where the SDK is packed and consumed. To avoid performance issues caused by parallel tests trying to repack the SDK simultaneously, use the following command:

# 1. Ensure artifacts are built (if running for the first time)
# Note: The test fixture will auto-build if artifacts/nuget is empty,
# but for optimal performance, set up the environment variables.

# 2. Run tests pointing to the artifacts directory
export CI=true
export NUGET_DIRECTORY="$(pwd)/artifacts"
dotnet test tests/ANcpLua.Sdk.Tests

License

MIT


Credits

There are no supported framework assets in this package.

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 23 1/10/2026
1.6.1 26 1/10/2026
1.3.31 49 1/9/2026
1.3.30 34 1/9/2026
1.3.29 51 1/9/2026
1.3.28 86 1/9/2026
1.3.27 36 1/9/2026
1.3.26 41 1/9/2026
1.3.25 36 1/9/2026
1.3.24 37 1/9/2026
1.3.23 111 1/6/2026
1.3.22 99 1/6/2026
1.3.21 76 1/6/2026
1.3.20 87 1/2/2026
1.3.19 88 1/2/2026
1.3.18 120 1/1/2026
1.3.17 86 1/1/2026
1.3.16 92 12/31/2025
1.3.15 85 12/31/2025
1.3.14 85 12/31/2025
1.3.13 83 12/31/2025
1.3.12 87 12/31/2025
1.3.10 90 12/31/2025
1.3.9 84 12/31/2025
1.3.8 92 12/30/2025
1.3.7 153 12/30/2025
1.3.6 80 12/30/2025
1.3.5 91 12/30/2025
1.3.4 100 12/30/2025
1.3.3 87 12/30/2025
1.3.2 86 12/30/2025
1.3.1 86 12/30/2025
1.3.0 87 12/30/2025
1.2.4 98 12/29/2025
1.2.3 91 12/29/2025
1.2.2 91 12/29/2025
1.2.1 177 12/25/2025
1.2.0 199 12/24/2025
1.1.8 278 12/16/2025
1.1.7 267 12/16/2025
1.1.6 294 12/16/2025
1.1.5 256 12/16/2025
1.1.4 260 12/16/2025
1.1.3 261 12/16/2025
1.1.2 274 12/15/2025
1.1.1 239 12/15/2025
1.1.0 243 12/15/2025
1.0.0 167 12/14/2025