AutoMapperAnalyzer.Analyzers
2.30.39
See the version list below for details.
dotnet add package AutoMapperAnalyzer.Analyzers --version 2.30.39
NuGet\Install-Package AutoMapperAnalyzer.Analyzers -Version 2.30.39
<PackageReference Include="AutoMapperAnalyzer.Analyzers" Version="2.30.39"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="AutoMapperAnalyzer.Analyzers" Version="2.30.39" />
<PackageReference Include="AutoMapperAnalyzer.Analyzers"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add AutoMapperAnalyzer.Analyzers --version 2.30.39
#r "nuget: AutoMapperAnalyzer.Analyzers, 2.30.39"
#:package AutoMapperAnalyzer.Analyzers@2.30.39
#addin nuget:?package=AutoMapperAnalyzer.Analyzers&version=2.30.39
#tool nuget:?package=AutoMapperAnalyzer.Analyzers&version=2.30.39
๐ฏ AutoMapper Roslyn Analyzer
โจ Catch AutoMapper configuration errors before they cause runtime chaos
A sophisticated Roslyn analyzer that transforms AutoMapper development from reactive debugging to proactive prevention
๐ Latest Release: v2.30.39
CI action runtime hardening
โ Highlights
- CI, release, and CodeQL workflows now use current major action pins with Node.js 24-compatible releases.
- Checkout/setup-dotnet, Codecov, CodeQL, cache, upload-artifact, and GitHub release actions were refreshed without changing workflow behavior.
- Package smoke coverage still validates
net8.0,net9.0, andnet10.0consumers.
๐งช Validation
- Full solution test validation passed on
net10.0with 833 tests. - AnalyzerVerifier
--check-catalog --check-snapshotsgreen. - PR #114 CI/package smoke checks green.
Recent Releases
- v2.30.39: Refreshed CI, release, and CodeQL workflow action pins to current major versions with Node.js 24-compatible releases.
- v2.30.38: AM031 complex LINQ
SelectManydiagnostics now require realSystem.Linq.Enumerable/Queryablecalls, so user-defined namesakes with nested selector logic stay quiet. - v2.30.37: AM001 uses the exact C# implicit numeric conversion table, reports
double/floattodecimalmappings, and preserves valid widenings such aschartoint. - v2.30.36: AM002 preserves constructed generic type labels in nullable diagnostics and uses
default!for generic/reference fallback defaults in generated fixes. - v2.30.35: Split AM030's mixed converter diagnostics into AM030 invalid implementation, AM032 null handling, and AM033 unused converter rules with independent docs, severities, and trust metadata.
- v2.30.34: Calibrated AM021's analyzer-health Tests score to 5, aligning it with AM022 based on comparable analyzer coverage and stronger AM021 code-fix method count.
- v2.30.33: AM003 detects immutable/frozen destination container mismatches and offers fully qualified factory fixes for
ImmutableList<T>,ImmutableHashSet<T>, andFrozenSet<T>. - v2.30.32: AM004/AM006 diagnostics now point at the offending source/destination property identifiers while preserving code-fix routing through mapping invocation metadata.
- v2.30.31: Correctness/code-fix hardening from an adversarial audit โ AM001 signed/unsigned numeric mismatches, keyword-name escaping, AM020 qualified/generic nested
CreateMapnames, AM003 implicit-conversion-gated element casts, AM031ValueTask.Result. - v2.30.30: Added AM021 simple-conversion fixes for
ImmutableList<T>,ImmutableHashSet<T>, andFrozenSet<T>while keeping custom immutable-lookalikes manual-only. - v2.30.29: Hardened AM003 custom collection fixer safety while preserving safe BCL collection constructor rewrites.
- v2.30.28: Tightened AM031 and AM001 fixer action selection so automatic rewrites stay executable and behavior-preserving.
- v2.30.27: Added a direct AM041 test locking the
ForPathchained-configuration withhold behavior alongside the existingForMember/parenthesized/ReverseMap()-chained coverage. - v2.30.26: Locked AM050 sibling-config withhold behavior with direct
PreCondition/UseDestinationValue/Ignoreregression tests alongside the existingCondition/NullSubstitutecases. - v2.30.25: Corrected six AM002/AM011/AM020/AM021/AM022/AM030 rule-docs category lines to match the shipped descriptor categories and added a category drift guard that prevents future doc/descriptor drift.
- v2.30.24: Marked unwired AM003/AM030
DiagnosticDescriptorrelics[Obsolete](binary compatibility preserved) and added a trust drift guard that fails when any shipped analyzer declares aDiagnosticDescriptorfield outside itsSupportedDiagnosticswithout an explicit Obsolete attribute. - v2.30.23: AM050 code fix is withheld when the redundant-
MapFromForMemberlambda contains sibling configuration (Condition,NullSubstitute, โฆ) that would otherwise be dropped. - v2.30.22: AM031 normalises chained pre-terminal LINQ receivers so multiple enumerations of the same source-rooted collection report.
- v2.30.21: AM050 redundant-
MapFromdetection now also fires on parenthesized and typed lambdas such aso.MapFrom((Source s) => s.Name). - v2.30.20: AM030 recognises
ArgumentNullException.ThrowIfNull,ArgumentException.ThrowIfNullOrEmpty, andArgumentException.ThrowIfNullOrWhiteSpaceas null guards on the converter's source parameter. - v2.30.19: AM030 stops reporting concrete converters as unused when a matching
ITypeConverter<TSource, TDestination>is passed toConvertUsingthrough DI/service-locator shapes. - v2.30.18: AM031 multiple-enumeration tracking covers
Min,Max,Aggregate,LongCount,Single,SingleOrDefault,ToHashSet,ToDictionary, andToLookup, with aSystem.Linq.Enumerable/Queryablenamesake gate. - v2.30.17: AM041 withholds the duplicate-removal fix when the duplicate
CreateMap<>()carries chained mapping policy. - v2.30.16: Analyzer precision hardening across AM002, AM006, AM021, AM031, and AM041.
- v2.30.15: Fixer UX trust hardening with descriptor-specific no-fix metadata and executable interface collection rewrites.
- v2.30.14: AM021 reverse-map collection element diagnostics catch missing reverse element maps without duplicate noise.
- v2.30.13: AM041 duplicate-map labels now preserve generic type arguments and array ranks.
- v2.30.12: AM030 interface-typed converter usage and AM021 dictionary fixer safety.
- v2.30.11: AM001 enum/string conversion fixes for direct property mismatch remediation.
- v2.30.10: AM050 proven redundant
MapFromcleanup for string-based members and type-safe suppressions. - v2.30.9: AM004/AM005 severity documentation trust with descriptor-aligned rule docs.
- v2.30.8: AM030 null-guard fixer precision without invasive
using Systemedits. - v2.30.7: AM022 recursion boundary precision for nested-map chains and explicit recursion controls.
- v2.30.6: AM031 source collection cache precision with nested source paths and Task-property
.Resultcoverage. - v2.30.5: AM030 type-based converter usage precision for
ConvertUsing(typeof(...)). - v2.30.4: AM022 mapped recursion precision with unrelated-cycle false-positive reductions.
- v2.30.3: AM011 ForPath required-member boundary with explicit configuration coverage.
- v2.30.2: AM003 assignable collection boundary suppression with targeted regression coverage.
- v2.30.1: AM002 nullability contract alignment with descriptor-accurate docs and nullable-context regression coverage.
- v2.30.0: Fixer hardening for AM001, AM005, AM006, AM011, and AM021 with safer action selection.
- v2.29.0: Smart primary fix and reduced fixer noise across the main data-integrity fixers.
- v2.28.2: False-positive reduction, fixer UX improvements, and release workflow hardening.
- v2.28.1: Case-aware AM021 suppression and fixer reliability improvements.
- v2.28.0: Analyzer logic fixes and performance improvements.
- v2.27.0: AM050 nullable safety fix and broad regression coverage expansion.
- v2.25.0: Code-fix consolidation and sample verification.
๐ Why This Matters
AutoMapper is powerful, but silent failures are its Achilles' heel. Properties that don't map, type mismatches that throw at runtime, nullable violations that cause NullReferenceExceptionsโthese issues typically surface in production, not during development.
This analyzer changes that equation entirely.
// Before: ๐ฐ Runtime surprise!
public void MapUserData()
{
var user = mapper.Map<UserDto>(userEntity);
// ๐ฅ NullReferenceException in production
// ๐ฅ Data loss from unmapped properties
// ๐ฅ Type conversion failures
}
// After: ๐ก๏ธ Compile-time confidence!
public void MapUserData()
{
var user = mapper.Map<UserDto>(userEntity);
// โ
All mapping issues caught at compile-time
// โ
Code fixes suggest proper solutions
// โ
Ship with confidence
}
โก Quick Start
# Install via .NET CLI
dotnet add package AutoMapperAnalyzer.Analyzers
# Or via Package Manager Console
Install-Package AutoMapperAnalyzer.Analyzers
That's it! The analyzer automatically activates and starts checking your AutoMapper configurations. Open any file with AutoMapper mappings and see diagnostics appear instantly.
See it work:
var config = new MapperConfiguration(cfg =>
{
cfg.CreateMap<User, UserDto>();
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ AM001: Property 'Age' type mismatch
// ๐ก Press Ctrl+. for code fix suggestions
});
๐ What You Get
๐ก๏ธ Complete Type Safety
- AM001: Property type mismatches with smart conversion suggestions
- AM002: Nullable-to-non-nullable mapping with null safety patterns
- AM003: Collection type incompatibility detection
๐ Zero Data Loss
- AM004: Missing destination properties (prevent silent data loss)
- AM006: Unmapped destination properties (detect unintentional defaults)
- AM011: Required property validation (avoid runtime exceptions)
- AM005: Case sensitivity issues (cross-platform reliability)
๐งฉ Complex Mapping Intelligence
- AM020: Nested object mapping validation with CreateMap suggestions (supports internal properties & cross-profile detection)
- AM021: Collection element type analysis with conversion strategies
- AM022: Circular reference detection with MaxDepth recommendations
- AM030/AM032/AM033: Custom type converter implementation, null safety, and usage validation
โก Instant Code Fixes
Every analyzer comes with intelligent code fixes that don't just identify problemsโthey solve them:
// Problem detected โ ๏ธ
cfg.CreateMap<Source, Dest>();
// ~~~~~~~~~~~~~~~~~~~~~~~~~ AM001: Property 'Age' type mismatch
// Code fix applied โจ
cfg.CreateMap<Source, Dest>()
.ForMember(dest => dest.Age, opt => opt.MapFrom(src =>
int.TryParse(src.Age, out var age) ? age : 0));
๐ฏ Real-World Impact
| Before | After | |
|---|---|---|
| ๐ | Runtime mapping failures | โ Compile-time validation |
| ๐ | Manual debugging sessions | โ Instant error highlights |
| ๐ | Guessing correct configurations | โ Code fixes with best practices |
| โ ๏ธ | Production NullReferenceExceptions | โ Null safety enforcement |
| ๐ | Silent data loss | โ Missing property detection |
| ๐ | Cross-platform mapping inconsistencies | โ Case sensitivity validation |
๐ฆ Installation
.NET CLI (Recommended)
dotnet add package AutoMapperAnalyzer.Analyzers
Package Manager Console
Install-Package AutoMapperAnalyzer.Analyzers
Project File (For CI/CD)
<PackageReference Include="AutoMapperAnalyzer.Analyzers" Version="2.30.39">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
โก Universal Compatibility
| Platform | Version | Support | AutoMapper | CI/CD Status |
|---|---|---|---|---|
| .NET Framework | 4.8+ | ๐ข Full | 10.1.1+ | โ Tested |
| .NET | 6.0+ | ๐ข Full | 12.0.1+ | โ Tested |
| .NET | 8.0+ | ๐ข Full | 14.0.0+ | โ Tested |
| .NET | 9.0+ | ๐ข Full | 14.0.0+ | โ Tested |
| .NET | 10.0+ | ๐ข Full | 14.0.0+ | โ Tested |
Analyzer targets .NET Standard 2.0 for maximum compatibility
All platforms validated in automated CI/CD pipeline
๐จ See It In Action
โ The Problems
public class UserEntity
{
public int Id { get; set; }
public string? FirstName { get; set; } // Nullable
public string LastName { get; set; }
public string Email { get; set; }
public DateTime CreatedAt { get; set; }
public List<string> Tags { get; set; } // Collection type
public Address HomeAddress { get; set; } // Complex object
}
public class UserDto
{
public int Id { get; set; }
public string FirstName { get; set; } // Non-nullable!
public string FullName { get; set; } // Different property!
public string Age { get; set; } // Different type!
public HashSet<int> Tags { get; set; } // Incompatible collection!
public AddressDto HomeAddress { get; set; } // Needs explicit mapping!
}
// This configuration has MULTIPLE issues:
cfg.CreateMap<UserEntity, UserDto>();
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ๐จ AM002: FirstName nullableโnon-nullable (NullReferenceException risk)
// ๐จ AM004: LastName will not be mapped (data loss)
// ๐จ AM001: Age expects int but gets DateTime (runtime exception)
// ๐จ AM021: Tags List<string>โHashSet<int> incompatible (mapping failure)
// ๐จ AM020: HomeAddressโAddressDto needs CreateMap (runtime exception)
โ The Solutions (Auto-Generated!)
// Code fixes automatically suggest:
cfg.CreateMap<UserEntity, UserDto>()
.ForMember(dest => dest.FirstName, opt => opt.MapFrom(src => src.FirstName ?? ""))
.ForMember(dest => dest.FullName, opt => opt.MapFrom(src => $"{src.FirstName} {src.LastName}"))
.ForMember(dest => dest.Age, opt => opt.MapFrom(src =>
DateTime.Now.Year - src.CreatedAt.Year))
.ForMember(dest => dest.Tags, opt => opt.MapFrom(src =>
src.Tags.Select((tag, index) => index).ToHashSet()));
// Separate mapping for complex types
cfg.CreateMap<Address, AddressDto>();
โ๏ธ Fine-Tuned Control
Severity Configuration (.editorconfig)
# Treat type safety as build errors
dotnet_diagnostic.AM001.severity = error
dotnet_diagnostic.AM002.severity = error
dotnet_diagnostic.AM011.severity = error
# Data loss warnings
dotnet_diagnostic.AM004.severity = warning
dotnet_diagnostic.AM005.severity = warning
# Suggestions for optimization
dotnet_diagnostic.AM020.severity = suggestion
dotnet_diagnostic.AM021.severity = suggestion
Selective Suppression
// Suppress with clear justification
#pragma warning disable AM001 // Custom IValueConverter handles stringโint
cfg.CreateMap<Source, Dest>();
#pragma warning restore AM001
// Method-level suppression
[SuppressMessage("AutoMapper", "AM004:Missing destination property",
Justification = "PII data intentionally excluded for GDPR compliance")]
public void ConfigureSafeUserMapping() { }
๐ Complete Analyzer Coverage
| Rule | Description | Analyzer | Code Fix | Severity |
|---|---|---|---|---|
| ๐ Type Safety | ||||
| AM001 | Property Type Mismatch | โ | โ | Error |
| AM002 | NullableโNon-nullable | โ | โ | Error / Info |
| AM003 | Collection Incompatibility | โ | โ | Error |
| ๐ Data Integrity | ||||
| AM004 | Missing Destination Property | โ | โ | Warning |
| AM005 | Case Sensitivity Issues | โ | โ | Warning |
| AM006 | Unmapped Destination Property | โ | โ | Info |
| AM011 | Required Property Missing | โ | โ | Error |
| ๐งฉ Complex Mappings | ||||
| AM020 | Nested Object Issues | โ | โ | Warning |
| AM021 | Collection Element Mismatch | โ | โ | Warning |
| AM022 | Circular Reference Risk | โ | โ | Warning |
| AM030 | Invalid Type Converter Implementation | โ | โ | Error |
| AM032 | Type Converter Null Handling | โ | โ | Warning |
| AM033 | Unused Type Converter | โ | โ | Info |
| โก Performance | ||||
| AM031 | Performance Warnings | โ | โ | Warning / Info |
| โ๏ธ Configuration | ||||
| AM041 | Duplicate Mapping Registration | โ | โ | Warning |
| AM050 | Redundant MapFrom | โ | โ | Info |
| ๐ Future | ||||
| AM034+ | Advanced Null Propagation | ๐ฎ | ๐ฎ | - |
| AM040+ | Configuration Rules | ๐ฎ | ๐ฎ | - |
| AM050+ | Advanced Optimizations | ๐ฎ | ๐ฎ | - |
๐ ๏ธ Development Experience
IDE Integration
- Visual Studio: Full IntelliSense integration with lightbulb code fixes
- VS Code: Rich diagnostic experience via OmniSharp
- JetBrains Rider: Native analyzer support with quick-fix suggestions
- Command Line: Works seamlessly with
dotnet build
Testing Your Configuration
# Quick validation
dotnet build # Analyzer runs automatically
# Comprehensive testing
git clone https://github.com/georgepwall1991/automapper-analyser.git
cd automapper-analyser
dotnet run --project samples/AutoMapperAnalyzer.Samples
# See all analyzer warnings in action
dotnet build samples/ --verbosity normal
# Run full test suite with coverage
dotnet test --collect:"XPlat Code Coverage" --settings coverlet.runsettings
CI/CD & Quality Assurance
- ๐ Automated Testing: Every commit tested across multiple .NET versions
- ๐ Code Coverage: Integrated with Codecov for comprehensive coverage tracking
- ๐ก๏ธ Quality Gates: Build fails only on genuine errors, warnings are preserved
- โก Cross-Platform: Validated on Ubuntu (CI) and Windows (compatibility tests)
- ๐ Performance: Incremental builds with analyzer caching for optimal speed
๐๏ธ Architecture Highlights
This isn't just another analyzerโit's built for enterprise-grade reliability:
- ๐๏ธ Performance-First: Incremental analysis with minimal IDE impact
- ๐ง Extensible Design: Clean plugin architecture for new rules
- ๐งช Battle-Tested: release validation includes full suite coverage plus targeted regression tests for high-risk fixers
- ๐ Cross-Platform: Identical behavior on Windows, macOS, Linux
- โก CI/CD Ready: Automated GitHub Actions with codecov integration
- ๐ Code Coverage: 55%+ coverage with comprehensive testing
๐ฏ What's Next
Recently Completed โ
- v2.30.15: Fixer UX trust hardening with descriptor-specific no-fix metadata and executable interface collection rewrites
- v2.30.14: AM021 reverse-map collection element diagnostics catch missing reverse element maps without duplicate noise
- v2.30.13: AM041 duplicate-map labels preserve generic type arguments and array ranks
- v2.30.12: AM030 interface-typed converter usage and AM021 dictionary fixer safety
- v2.30.11: AM001 enum/string conversion fixes for direct property mismatch remediation
- v2.30.10: AM050 proven redundant
MapFromcleanup for string-based members and type-safe suppressions - v2.30.9: AM004/AM005 severity documentation trust with descriptor-aligned rule docs
- v2.30.8: AM030 null-guard fixer precision without invasive
using Systemedits - v2.30.7: AM022 recursion boundary precision for nested-map chains and explicit recursion controls
- v2.30.6: AM031 source collection cache precision with nested source paths and Task-property
.Resultcoverage - v2.30.5: AM030 type-based converter usage precision for
ConvertUsing(typeof(...)) - v2.30.4: AM022 mapped recursion precision with unrelated-cycle false-positive reductions
- v2.30.3: AM011 ForPath required-member boundary with explicit-configuration regression coverage
- v2.30.2: AM003 assignable collection boundary suppression with targeted regression coverage
- v2.30.1: AM002 nullability contract alignment with descriptor-accurate docs and nullable-context regression coverage
- v2.30.0: Fixer hardening for AM001, AM005, AM006, AM011, and AM021 with safer action selection
- v2.29.0: Smart Primary Fix โ reduced fixer noise to max 2 lightbulb options per diagnostic
- v2.28.2: False-positive reduction, fixer UX improvements, and release workflow hardening
- v2.28.1: Case-aware AM021 suppression and fixer accuracy improvements
- v2.28.0: Analyzer logic fixes and performance improvements
- v2.27.0: AM050 nullable safety fix and expanded regression coverage
Phase 5B: Enhanced Analysis (Upcoming)
- AM034: Advanced null propagation patterns with smart fixes
Phase 6: Configuration & Profile Analysis
- AM040: Profile registration analysis and auto-registration fixes
Beyond Code Analysis
- NuGet Package Templates: Project templates with pre-configured analyzers
- MSBuild Integration: Custom build targets for mapping validation
- Documentation Generation: Auto-generate mapping documentation
- Metrics Dashboard: Build-time analysis reporting
๐ค Contributing
We're building something special, and your expertise makes it better.
Quick Start Contributing:
git clone https://github.com/georgepwall1991/automapper-analyser.git
cd automapper-analyser
dotnet test
What We Need:
- ๐งช More edge-case scenarios
- ๐ Documentation improvements
- ๐ Performance optimizations
- ๐ก New analyzer rule ideas
See our Contributing Guide for detailed guidelines.
๐ Deep Dive Resources
- ๐ Architecture Guide - How it all works under the hood
- ๐ Diagnostic Rules - Complete rule reference
- ๐งญ Generated Rule Catalog - Descriptor, fixer, sample, and trust-level source of truth
- ๐งช Sample Gallery - Real-world scenarios
- ๐ CI/CD Pipeline - Our build and deployment process
- ๐ Compatibility Matrix - Framework support details
๐ฌ Community & Support
Get Help:
- ๐ Issues - Bug reports and feature requests
- ๐ฌ Discussions - Questions and ideas
- ๐ Wiki - Comprehensive documentation
๐ License
MIT License - Use it anywhere, contribute back if you can.
<div align="center">
โญ Star this repo if it's saving you time!
Built with โค๏ธ by developers who've debugged too many AutoMapper issues
๐ Get Started Now โข ๐ Read the Docs โข ๐ฌ **Join the Discussion **
</div>
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- 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 |
|---|---|---|
| 2.30.51 | 3 | 6/7/2026 |
| 2.30.50 | 13 | 6/7/2026 |
| 2.30.49 | 46 | 6/6/2026 |
| 2.30.48 | 52 | 6/4/2026 |
| 2.30.47 | 50 | 6/4/2026 |
| 2.30.46 | 54 | 6/4/2026 |
| 2.30.45 | 69 | 6/4/2026 |
| 2.30.44 | 73 | 6/4/2026 |
| 2.30.43 | 72 | 6/3/2026 |
| 2.30.42 | 71 | 6/3/2026 |
| 2.30.41 | 75 | 6/3/2026 |
| 2.30.40 | 69 | 6/3/2026 |
| 2.30.39 | 66 | 6/3/2026 |
| 2.30.38 | 74 | 6/3/2026 |
| 2.30.37 | 73 | 6/3/2026 |
| 2.30.36 | 70 | 6/3/2026 |
| 2.30.35 | 70 | 6/3/2026 |
| 2.30.34 | 69 | 6/3/2026 |
| 2.30.33 | 71 | 6/3/2026 |
| 2.30.32 | 75 | 6/3/2026 |
Version 2.30.39 - CI action runtime hardening
Changed:
- Refreshed CI, release, and CodeQL workflow action pins to current major versions with Node.js 24-compatible releases
- Updated checkout/setup-dotnet, Codecov, CodeQL, cache, upload-artifact, and GitHub release actions
- Preserved existing build, package, release, and smoke-test behavior
Validation:
- Full solution test suite passing on net10.0 (833 tests)
- Rule catalog and sample diagnostics snapshot checks passing
- PR #114 CI/package smoke checks passing
- git diff --check clean
Previous Release: v2.30.38 - AM031 LINQ namesake precision