ANcpLua.Roslyn.Utilities 1.10.0

dotnet add package ANcpLua.Roslyn.Utilities --version 1.10.0
                    
NuGet\Install-Package ANcpLua.Roslyn.Utilities -Version 1.10.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" Version="1.10.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ANcpLua.Roslyn.Utilities" Version="1.10.0" />
                    
Directory.Packages.props
<PackageReference Include="ANcpLua.Roslyn.Utilities" />
                    
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.Roslyn.Utilities --version 1.10.0
                    
#r "nuget: ANcpLua.Roslyn.Utilities, 1.10.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@1.10.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&version=1.10.0
                    
Install as a Cake Addin
#tool nuget:?package=ANcpLua.Roslyn.Utilities&version=1.10.0
                    
Install as a Cake Tool

NuGet NuGet .NET Standard 2.0 License

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.Sdk directly (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.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on ANcpLua.Roslyn.Utilities:

Package Downloads
ANcpLua.Roslyn.Utilities.Testing

Fluent testing framework for Roslyn analyzers, code fixes, and incremental generators with caching validation, forbidden type detection, and comprehensive assertion support.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.10.0 30 1/10/2026
1.9.0 31 1/10/2026
1.8.0 34 1/10/2026
1.7.0 64 1/10/2026
1.6.0 40 1/9/2026
1.5.1 37 1/9/2026
1.5.0 35 1/8/2026
1.3.1 96 12/30/2025
1.2.8 90 12/30/2025
1.2.7 94 12/30/2025
1.2.6 81 12/30/2025
1.2.4 81 12/30/2025
1.2.2 89 12/29/2025
1.2.1 90 12/29/2025
1.2.0 190 12/24/2025
1.0.0 143 12/20/2025