NPipeline.Analyzers
0.15.0
dotnet add package NPipeline.Analyzers --version 0.15.0
NuGet\Install-Package NPipeline.Analyzers -Version 0.15.0
<PackageReference Include="NPipeline.Analyzers" Version="0.15.0"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="NPipeline.Analyzers" Version="0.15.0" />
<PackageReference Include="NPipeline.Analyzers"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add NPipeline.Analyzers --version 0.15.0
#r "nuget: NPipeline.Analyzers, 0.15.0"
#:package NPipeline.Analyzers@0.15.0
#addin nuget:?package=NPipeline.Analyzers&version=0.15.0
#tool nuget:?package=NPipeline.Analyzers&version=0.15.0
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
- ValueTaskOptimizationAnalyzer - Identifies opportunities to optimize synchronous completions with ValueTask
Configuration Analyzers
- BatchingConfigurationMismatchAnalyzer - Detects mismatched batch size and timeout configurations
- InappropriateParallelismConfigurationAnalyzer - Identifies inappropriate parallelism settings that can cause resource contention
- TimeoutConfigurationAnalyzer - Detects timeout values that are too short or too long for the workload type
- UnboundedMaterializationConfigurationAnalyzer - Identifies potential memory leaks from unbounded materialization
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
Pipeline-Specific Analyzers
- DependencyInjectionAnalyzer - Detects dependency injection anti-patterns in node implementations
- PipelineContextAccessAnalyzer - Identifies unsafe access patterns on PipelineContext properties
- ResilientExecutionConfigurationAnalyzer - Validates resilient execution strategy configurations
- SinkNodeInputConsumptionAnalyzer - Ensures proper consumption of input in sink nodes
- SourceNodeStreamingAnalyzer - Detects non-streaming patterns in source nodes
Supported Code Fix Providers (18)
Each analyzer has a corresponding code fix provider that 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
- ResilientExecutionConfigurationCodeFixProvider - Configures resilient execution strategies
- 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
- TimeoutConfigurationCodeFixProvider - Optimizes timeout values based on workload characteristics
- UnboundedMaterializationConfigurationCodeFixProvider - Adds bounds to materialization operations
- ValueTaskOptimizationCodeFixProvider - Converts Task.FromResult patterns to ValueTask
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: NPIPE001: Use StringBuilder or string interpolation for efficient string concatenation
// LINQ in hot path
public List<Result> TransformItems(List<Item> items)
{
return items.Where(x => x.IsValid)
.Select(x => new Result(x))
.ToList();
}
// Diagnostic: NPIPE002: Avoid LINQ operations in hot paths
Configuration Issues
// Inappropriate parallelism for I/O-bound work
var strategy = new ParallelExecutionStrategy
{
DegreeOfParallelism = Environment.ProcessorCount
};
// Diagnostic: NPIPE003: High parallelism for I/O-bound work may cause resource contention
// Timeout too short for complex processing
var resilientStrategy = new ResilientExecutionStrategy
{
Timeout = TimeSpan.FromMilliseconds(100)
};
// Diagnostic: NPIPE004: Timeout may be too short for the workload type
Async/Await Issues
// Blocking on async code
public void ProcessData()
{
var result = GetDataAsync().Result;
}
// Diagnostic: NPIPE005: Avoid blocking on async operations
// Not respecting cancellation token
public async Task ProcessAsync(CancellationToken cancellationToken)
{
await ProcessItemAsync(); // Missing cancellationToken parameter
}
// Diagnostic: NPIPE006: Async 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.NPIPE001.severity = warning
dotnet_diagnostic.NPIPE002.severity = suggestion
# Disable specific analyzers
dotnet_diagnostic.NPIPE003.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
MIT License - see LICENSE file for details.
| 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.15.0 | 39 | 2/19/2026 |
| 0.14.0 | 36 | 2/17/2026 |
| 0.13.1 | 81 | 2/13/2026 |
| 0.13.0 | 83 | 2/13/2026 |
| 0.12.0 | 86 | 2/9/2026 |
| 0.11.0 | 84 | 2/8/2026 |
| 0.10.0 | 89 | 2/6/2026 |
| 0.9.1 | 84 | 2/5/2026 |
| 0.9.0 | 83 | 2/5/2026 |
| 0.8.0 | 86 | 2/3/2026 |
| 0.7.1 | 88 | 2/1/2026 |
| 0.7.0 | 89 | 1/31/2026 |
| 0.6.6 | 97 | 1/21/2026 |
| 0.6.5 | 91 | 1/19/2026 |
| 0.6.4 | 90 | 1/18/2026 |
| 0.6.3 | 90 | 1/14/2026 |
| 0.6.2 | 90 | 1/13/2026 |
| 0.6.1 | 96 | 1/13/2026 |
| 0.6.0 | 98 | 1/13/2026 |
| 0.5.0 | 93 | 1/11/2026 |