ANcpLua.Roslyn.Utilities.Testing
1.10.0
dotnet add package ANcpLua.Roslyn.Utilities.Testing --version 1.10.0
NuGet\Install-Package ANcpLua.Roslyn.Utilities.Testing -Version 1.10.0
<PackageReference Include="ANcpLua.Roslyn.Utilities.Testing" Version="1.10.0" />
<PackageVersion Include="ANcpLua.Roslyn.Utilities.Testing" Version="1.10.0" />
<PackageReference Include="ANcpLua.Roslyn.Utilities.Testing" />
paket add ANcpLua.Roslyn.Utilities.Testing --version 1.10.0
#r "nuget: ANcpLua.Roslyn.Utilities.Testing, 1.10.0"
#:package ANcpLua.Roslyn.Utilities.Testing@1.10.0
#addin nuget:?package=ANcpLua.Roslyn.Utilities.Testing&version=1.10.0
#tool nuget:?package=ANcpLua.Roslyn.Utilities.Testing&version=1.10.0
ANcpLua.Roslyn.Utilities
Comprehensive utilities for Roslyn analyzers and source generators.
CRITICAL: Layer 0 Package - No SDK Dependency Allowed
This is an upstream package in the ANcpLua ecosystem. It CANNOT depend on ANcpLua.NET.Sdk. Any such dependency would create a circular reference and break the entire build chain.
Dependency Hierarchy
Layer 0: ANcpLua.Roslyn.Utilities <- YOU ARE HERE (publishes first)
|
v
Layer 1: ANcpLua.NET.Sdk <- Consumes this package
|
v
Layer 2: Downstream repos <- Consume the SDK
Why this matters:
- This package must be published to NuGet before ANcpLua.NET.Sdk can reference it
- Uses
Microsoft.NET.Sdkdirectly (not any custom SDK) - Uses PolySharp for netstandard2.0 polyfills instead of SDK-provided polyfills
- CI enforcement: GitHub Actions checks fail if any ANcpLua.NET.Sdk dependency is detected
Installation
dotnet add package ANcpLua.Roslyn.Utilities
dotnet add package ANcpLua.Roslyn.Utilities.Testing
Packages
| Package | Target | Description |
|---|---|---|
| ANcpLua.Roslyn.Utilities | netstandard2.0 | Core library with EquatableArray, symbol extensions, pipeline extensions, DiagnosticFlow |
| ANcpLua.Roslyn.Utilities.Testing | net10.0 | Testing framework for incremental generators with caching validation |
Building
# Build
dotnet build -c Release
# Pack
dotnet pack -c Release
Highlights
DiagnosticFlow - Railway-Oriented Programming
Never lose diagnostics in your pipeline:
symbol.ToFlow(nullDiag)
.Then(ValidateMethod)
.Where(m => m.IsAsync, asyncRequired)
.WarnIf(m => m.IsObsolete, obsoleteWarn)
.Then(GenerateCode);
// Pipeline integration
provider
.SelectFlow(ExtractModel)
.ThenFlow(ValidateModel)
.ReportAndContinue(context)
.AddSource(context);
Symbol Pattern Matching
Replace 50-line if-statements with composable patterns:
var asyncTask = SymbolPattern.Method()
.Async()
.ReturnsTask()
.WithCancellationToken()
.Public()
.Build();
if (asyncTask.Matches(method)) { ... }
SemanticGuard - Declarative Validation
SemanticGuard.ForMethod(method)
.MustBeAsync(asyncRequired)
.MustReturnTask(taskRequired)
.MustHaveCancellationToken(ctRequired)
.ToFlow(); // -> DiagnosticFlow<IMethodSymbol>
API Overview
| Category | Key APIs |
|---|---|
| Flow Control | DiagnosticFlow<T>, ReportAndContinue() |
| Pattern Matching | SymbolPattern.*, Match.*, Invoke.* |
| Validation | SemanticGuard<T>, MustBeAsync(), MustBePartial() |
| Domain Contexts | AwaitableContext, AspNetContext, DisposableContext, CollectionContext |
| Operations | OperationExtensions, InvocationExtensions, OverloadFinder |
| Code Generation | IndentedStringBuilder, GeneratedCodeHelpers |
| Pipeline | GroupBy(), Batch(), Distinct(), CollectFlows() |
Symbol Extensions
// Core
symbol.IsEqualTo(other)
symbol.HasAttribute("Full.Name")
symbol.IsVisibleOutsideOfAssembly()
// Type checking
type.InheritsFrom(baseType)
type.Implements(interfaceType)
type.IsTaskType() / IsSpanType() / IsEnumerableType()
// Methods
method.IsInterfaceImplementation()
method.IsOrOverrideMethod(baseMethod)
Operation Extensions
// Navigation
operation.Ancestors()
operation.FindAncestor<TOperation>()
operation.Descendants()
// Context
operation.IsInExpressionTree()
operation.IsInsideLoop()
operation.IsInsideTryBlock()
// Invocations
invocation.GetArgument("name")
invocation.IsLinqMethod()
invocation.AllArgumentsAreConstant()
Domain Contexts
Pre-cached symbol lookups for common patterns:
var ctx = new AwaitableContext(compilation);
ctx.IsTaskLike(type)
ctx.IsAwaitable(type)
ctx.CanUseAsyncKeyword(method)
var asp = new AspNetContext(compilation);
asp.IsController(type)
asp.IsAction(method)
asp.IsFromBody(parameter)
var disp = new DisposableContext(compilation);
disp.IsDisposable(type)
disp.HasDisposeMethod(type)
var coll = new CollectionContext(compilation);
coll.IsImmutable(type)
coll.GetElementType(type)
Code Generation
var sb = new IndentedStringBuilder();
using (sb.BeginNamespace("MyNamespace"))
using (sb.BeginClass("public partial", "MyClass"))
using (sb.BeginMethod("public", "void", "Execute"))
{
sb.AppendLine("// generated code");
}
Pipeline Extensions
provider
.SelectFlow(ExtractModel)
.ThenFlow(ValidateModel)
.WarnIf(m => m.IsOld, obsoleteWarn)
.ReportAndContinue(context)
.AddSource(context);
// Collection operations
provider.GroupBy(keySelector)
provider.Batch(100)
provider.Distinct()
provider.CollectAsEquatableArray()
Testing Library
using var result = await Test<MyGenerator>.Run(source);
result
.Produces("Output.g.cs", expectedContent)
.IsCached()
.IsClean()
.HasNoForbiddenTypes();
Full Documentation
See CLAUDE.md for complete API reference.
Related
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- ANcpLua.Roslyn.Utilities (>= 1.10.0)
- AwesomeAssertions (>= 9.3.0)
- Basic.Reference.Assemblies.Net100 (>= 1.8.4)
- Basic.Reference.Assemblies.NetStandard20 (>= 1.8.4)
- Meziantou.Framework (>= 5.0.7)
- Meziantou.Framework.FullPath (>= 1.1.12)
- Meziantou.Framework.TemporaryDirectory (>= 1.0.30)
- Meziantou.Framework.Threading (>= 2.0.3)
- Microsoft.Bcl.HashCode (>= 6.0.0)
- Microsoft.CodeAnalysis.Analyzer.Testing (>= 1.1.3-beta1.25564.1)
- Microsoft.CodeAnalysis.CSharp (>= 5.0.0)
- Microsoft.CodeAnalysis.CSharp.Analyzer.Testing (>= 1.1.3-beta1.25564.1)
- Microsoft.CodeAnalysis.CSharp.CodeFix.Testing (>= 1.1.3-beta1.25564.1)
- Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing (>= 1.1.3-beta1.25564.1)
- Microsoft.CodeAnalysis.CSharp.Workspaces (>= 5.0.0)
- Microsoft.Deployment.DotNet.Releases (>= 1.0.1)
- MSBuild.StructuredLogger (>= 2.3.113)
- xunit.v3.assert (>= 3.2.1)
- xunit.v3.extensibility.core (>= 3.2.1)
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.10.0 | 33 | 1/10/2026 |
| 1.9.0 | 36 | 1/10/2026 |
| 1.8.0 | 35 | 1/10/2026 |
| 1.7.0 | 65 | 1/10/2026 |
| 1.6.0 | 35 | 1/9/2026 |
| 1.5.1 | 36 | 1/9/2026 |
| 1.5.0 | 38 | 1/8/2026 |
| 1.3.1 | 55 | 12/30/2025 |
| 1.2.8 | 48 | 12/30/2025 |
| 1.2.7 | 48 | 12/30/2025 |
| 1.2.6 | 40 | 12/30/2025 |
| 1.2.4 | 43 | 12/30/2025 |
| 1.2.2 | 43 | 12/29/2025 |
| 1.2.1 | 45 | 12/29/2025 |
| 1.2.0 | 147 | 12/24/2025 |
| 1.0.0 | 101 | 12/20/2025 |