ANcpLua.Roslyn.Utilities.Testing
1.5.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package ANcpLua.Roslyn.Utilities.Testing --version 1.5.0
NuGet\Install-Package ANcpLua.Roslyn.Utilities.Testing -Version 1.5.0
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.Roslyn.Utilities.Testing" Version="1.5.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ANcpLua.Roslyn.Utilities.Testing" Version="1.5.0" />
<PackageReference Include="ANcpLua.Roslyn.Utilities.Testing" />
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.Roslyn.Utilities.Testing --version 1.5.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ANcpLua.Roslyn.Utilities.Testing, 1.5.0"
#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.Roslyn.Utilities.Testing@1.5.0
#: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.Roslyn.Utilities.Testing&version=1.5.0
#tool nuget:?package=ANcpLua.Roslyn.Utilities.Testing&version=1.5.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ANcpLua.Roslyn.Utilities
Comprehensive utilities for Roslyn analyzers and source generators.
dotnet add package ANcpLua.Roslyn.Utilities
dotnet add package ANcpLua.Roslyn.Utilities.Testing
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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- ANcpLua.Roslyn.Utilities (>= 1.5.0)
- AwesomeAssertions (>= 9.3.0)
- Basic.Reference.Assemblies.Net100 (>= 1.8.4)
- Meziantou.Framework.FullPath (>= 1.1.12)
- Meziantou.Framework.TemporaryDirectory (>= 1.0.30)
- Microsoft.Bcl.HashCode (>= 6.0.0)
- Microsoft.CodeAnalysis.Analyzer.Testing (>= 1.1.3-beta1.24423.1)
- Microsoft.CodeAnalysis.Common (>= 5.0.0)
- Microsoft.CodeAnalysis.CSharp (>= 5.0.0)
- Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing (>= 1.1.3-beta1.24423.1)
- Microsoft.CodeAnalysis.CSharp.Workspaces (>= 5.0.0)
- Microsoft.Sbom.Targets (>= 4.1.5)
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.13.0 | 0 | 1/18/2026 |
| 1.12.0 | 79 | 1/14/2026 |
| 1.11.0 | 37 | 1/14/2026 |
| 1.10.0 | 174 | 1/10/2026 |
| 1.9.0 | 43 | 1/10/2026 |
| 1.8.0 | 43 | 1/10/2026 |
| 1.7.0 | 86 | 1/10/2026 |
| 1.6.0 | 43 | 1/9/2026 |
| 1.5.1 | 44 | 1/9/2026 |
| 1.5.0 | 45 | 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 | 102 | 12/20/2025 |