NPipeline.Analyzers
0.66.1
dotnet add package NPipeline.Analyzers --version 0.66.1
NuGet\Install-Package NPipeline.Analyzers -Version 0.66.1
<PackageReference Include="NPipeline.Analyzers" Version="0.66.1"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="NPipeline.Analyzers" Version="0.66.1" />
<PackageReference Include="NPipeline.Analyzers"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add NPipeline.Analyzers --version 0.66.1
#r "nuget: NPipeline.Analyzers, 0.66.1"
#:package NPipeline.Analyzers@0.66.1
#addin nuget:?package=NPipeline.Analyzers&version=0.66.1
#tool nuget:?package=NPipeline.Analyzers&version=0.66.1
NPipeline Analyzers
NPipeline Analyzers is a comprehensive Roslyn analyzer package designed to help developers build efficient, robust, and performant data processing pipelines using the NPipeline framework. This package provides real-time diagnostics and code fixes to detect and resolve common pipeline configuration issues, performance bottlenecks, and anti-patterns.
About NPipeline
NPipeline is a high-performance, extensible data processing framework for .NET that enables developers to build scalable and efficient pipeline-based applications. It provides a rich set of components for data transformation, aggregation, branching, and parallel processing, with built-in support for resilience patterns and error handling.
Installation
dotnet add package NPipeline.Analyzers
Requirements
- .NET Standard 2.0 compatible IDE
- Visual Studio 2017+ or JetBrains Rider or VS Code with C# extension
- C# 8.0 or later for full feature support
Features
- Real-time Diagnostics: Detects common pipeline configuration issues and performance anti-patterns as you code
- Automated Code Fixes: Provides one-click fixes for most detected issues
- Performance Optimization: Identifies bottlenecks in hot paths and suggests optimizations
- Resilience Patterns: Ensures proper error handling and cancellation token usage
- Configuration Validation: Validates pipeline configuration parameters for optimal performance
- Async/Await Best Practices: Enforces proper async patterns in pipeline implementations
Supported Analyzers (18)
The package includes 18 comprehensive analyzers covering different aspects of pipeline development:
Performance Analyzers
- AnonymousObjectAllocationAnalyzer - Detects anonymous object allocations in hot paths that can cause GC pressure
- InefficientStringOperationsAnalyzer - Identifies inefficient string concatenation and manipulation in performance-critical code
- LinqInHotPathsAnalyzer - Detects LINQ operations in high-frequency execution paths that cause unnecessary allocations
Configuration Analyzers
- BatchingConfigurationMismatchAnalyzer - Detects mismatched batch size and timeout configurations
- InappropriateParallelismConfigurationAnalyzer - Identifies inappropriate parallelism settings that can cause resource contention
- TimeoutConfigurationAnalyzer - Detects circuit breaker timings that cannot work (non-positive durations, or a
MaxPauseshorter thanOpenDurationwithWhenOpen = Pause)
Async/Cancellation Analyzers
- BlockingAsyncOperationAnalyzer - Detects blocking calls on async operations that can cause deadlocks
- CancellationTokenRespectAnalyzer - Ensures proper cancellation token propagation and usage
- SynchronousOverAsyncAnalyzer - Identifies synchronous-over-asynchronous anti-patterns
Error Handling Analyzers
- InefficientExceptionHandlingAnalyzer - Detects inefficient exception handling patterns in hot paths
- OperationCanceledExceptionAnalyzer - Ensures proper handling of OperationCanceledException
- NodeKindResilienceMisuseAnalyzer - Detects
ItemRetry,NodeRestart, orCircuitBreakerconfigured for a source, sink, aggregate, or join node - UnconditionalRetryDecisionAnalyzer - Detects a resilience policy that returns
Retrywithout consultingfailure.CanRetry
Pipeline-Specific Analyzers
- DependencyInjectionAnalyzer - Detects dependency injection anti-patterns in node implementations
- PipelineContextAccessAnalyzer - Identifies unsafe access patterns on PipelineContext properties
- ResilientExecutionConfigurationAnalyzer - Detects
RestartNodereturned where it cannot restart a node, or whereNodeRestartis never enabled - SinkNodeInputConsumptionAnalyzer - Ensures proper consumption of input in sink nodes
- SourceNodeStreamingAnalyzer - Detects non-streaming patterns in source nodes
Supported Code Fix Providers (14)
These code fix providers can automatically resolve detected issues:
- AnonymousObjectAllocationCodeFixProvider - Converts anonymous objects to named types or ValueTuples
- BatchingConfigurationMismatchCodeFixProvider - Adjusts batch size and timeout configurations
- BlockingAsyncOperationCodeFixProvider - Replaces blocking calls with async alternatives
- CancellationTokenRespectCodeFixProvider - Adds cancellation tokens to method signatures and calls
- DependencyInjectionCodeFixProvider - Refactors to proper dependency injection patterns
- InappropriateParallelismConfigurationCodeFixProvider - Optimizes parallelism settings based on workload
- InefficientExceptionHandlingCodeFixProvider - Refactors exception handling for better performance
- InefficientStringOperationsCodeFixProvider - Replaces inefficient string operations with optimized alternatives
- LinqInHotPathsCodeFixProvider - Converts LINQ operations to more efficient foreach loops
- OperationCanceledExceptionCodeFixProvider - Adds proper OperationCanceledException handling
- PipelineContextAccessCodeFixProvider - Adds null checks and conditional operators for safe access
- SinkNodeInputConsumptionCodeFixProvider - Adds proper async enumeration for input consumption
- SourceNodeStreamingCodeFixProvider - Converts to streaming patterns for source nodes
- SynchronousOverAsyncCodeFixProvider - Replaces sync-over-async patterns with proper async
Example Diagnostics
Performance Issues
// Inefficient string concatenation in a hot path
public string ProcessItem(Item item)
{
string result = "Processing: " + item.Name + " at " + DateTime.Now;
return result;
}
// Diagnostic: NP9104: Inefficient string operation detected
// LINQ in hot path
public List<Result> TransformItems(List<Item> items)
{
return items.Where(x => x.IsValid)
.Select(x => new Result(x))
.ToList();
}
// Diagnostic: NP9103: LINQ operation detected in hot path
Configuration Issues
// Inappropriate parallelism for I/O-bound work
var strategy = new ParallelExecutionStrategy
{
DegreeOfParallelism = Environment.ProcessorCount
};
// Diagnostic: NP9003: Inappropriate parallelism configuration detected
// Item retry on a sink: only transform nodes retry items
builder.WithResilience(sink, o => o with { ItemRetry = ItemRetryOptions.Default });
// Diagnostic: NP9204: 'sink' is a sink node, but its resilience options set ItemRetry, which only transform nodes use; building the pipeline will fail
Async/Await Issues
// Blocking on async code
public void ProcessData()
{
var result = GetDataAsync().Result;
}
// Diagnostic: NP9101: Avoid blocking calls in async methods
// Not respecting cancellation token
public async Task ProcessAsync(CancellationToken cancellationToken)
{
await ProcessItemAsync(); // Missing cancellationToken parameter
}
// Diagnostic: NP9203: Method should respect cancellation token
Troubleshooting
Analyzers Not Running
Ensure the package is installed in the project you're working on
Restart Visual Studio after installing the package
Check that analyzers are enabled in your project settings:
<PropertyGroup> <EnableNETAnalyzers>true</EnableNETAnalyzers> <AnalysisMode>AllEnabledByDefault</AnalysisMode> </PropertyGroup>
Code Fixes Not Available
- Make sure the diagnostic is active (not suppressed)
- Check that the file is saved - some fixes require saved files
- Verify the fix is applicable - not all issues have automatic fixes
Performance Impact
The analyzers are designed to have minimal impact on build performance:
- Most analysis is incremental and only runs on changed files
- Complex analyses are limited to specific contexts (hot paths, pipeline nodes)
- Caching is used to avoid redundant analysis
If you experience performance issues:
- Update to the latest version of the package
- Exclude test projects from analysis if not needed
- Consider disabling specific analyzers that aren't relevant to your project
Configuration
You can configure the behavior of the analyzers using an .editorconfig file:
# Severity levels
dotnet_diagnostic.NP9104.severity = warning
dotnet_diagnostic.NP9103.severity = suggestion
# Disable specific analyzers
dotnet_diagnostic.NP9003.severity = none
# Configure hot path detection
dotnet_code_quality.maximum_hot_path_complexity = 20
Integration with Build Process
The analyzers integrate seamlessly with your build process:
# Build with warnings as errors
dotnet build --warnaserror
# Run specific analyzers
dotnet build -p:RunAnalyzers=true -p:AnalyzerPlugins=NPipeline.Analyzers
Contributing
We welcome contributions to the NPipeline Analyzers package! Here's how you can help:
Reporting Issues
- Check existing issues to avoid duplicates
- Provide a minimal reproduction when reporting bugs
- Include diagnostic IDs and code examples when possible
- Describe the expected vs. actual behavior
Submitting Pull Requests
- Fork the repository and create a feature branch
- Follow the existing code style and patterns
- Add tests for new analyzers or fixes
- Update documentation for any new features
- Ensure all tests pass before submitting
Development Setup
# Clone the repository
git clone https://github.com/npipeline/NPipeline.git
cd NPipeline
# Build the solution
dotnet build
# Run tests
dotnet test
# Pack the analyzer package
dotnet pack src/NPipeline.Analyzers.Package
Adding New Analyzers
When adding a new analyzer:
- Inherit from DiagnosticAnalyzer and use the
[DiagnosticAnalyzer]attribute - Follow the naming convention:
[Name]Analyzer.cs - Provide clear diagnostic messages with actionable advice
- Implement a corresponding code fix provider when possible
- Add comprehensive tests covering various scenarios
- Update the documentation with the new analyzer's purpose and usage
Code Style
- Follow C# conventions as defined in
.editorconfig - Use XML documentation for public APIs
- Keep methods small and focused
- Add unit tests for all functionality
- Use meaningful variable and method names
License
This package is licensed under the MIT License. You are free to use, modify, and distribute it in personal, open-source, and commercial projects without restriction.
| Product | Versions 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. |
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 |
|---|---|---|
| 0.66.1 | 0 | 9/28/2026 |
| 0.66.0 | 0 | 9/28/2026 |
| 0.65.1 | 37 | 9/27/2026 |
| 0.65.0 | 38 | 9/26/2026 |
| 0.64.0 | 42 | 9/26/2026 |
| 0.63.0 | 41 | 9/24/2026 |
| 0.62.0 | 36 | 9/24/2026 |
| 0.61.1 | 43 | 9/22/2026 |
| 0.61.0 | 40 | 9/22/2026 |
| 0.60.0 | 79 | 9/22/2026 |
| 0.59.0 | 81 | 9/21/2026 |
| 0.58.0 | 81 | 9/21/2026 |
| 0.57.0 | 83 | 9/21/2026 |
| 0.56.0 | 74 | 9/21/2026 |
| 0.55.0 | 85 | 9/21/2026 |
| 0.54.1 | 83 | 9/21/2026 |
| 0.54.0 | 87 | 9/19/2026 |
| 0.53.2 | 92 | 9/9/2026 |
| 0.53.1 | 142 | 6/12/2026 |
| 0.53.0 | 122 | 6/11/2026 |