Skip to content

Add configuration-based mapping generator with 4 registration approaches - #11

Merged
davidkallesen merged 7 commits into
mainfrom
feature/Mapping-Configuration
Mar 13, 2026
Merged

davidkallesen merged 7 commits into
mainfrom
feature/Mapping-Configuration

Conversation

@davidkallesen

Copy link
Copy Markdown
Contributor

Summary

Adds a new MappingConfigurationGenerator that enables mapping 3rd-party types without requiring attributes on source types.
Introduces four complementary mapping approaches: mapper class pattern, assembly-level [MapTypes], class-level [MapTypes], and
inline MappingBuilder.Configure(). Also includes performance optimizations across all generators, shared helper extraction,
comprehensive test coverage, and documentation migration to GitHub wiki.

Changes

✨ Features

  • Add MappingConfigurationGenerator with mapper class pattern ([MappingConfiguration] + partial methods) for full-control
    3rd-party type mapping
  • Add assembly-level and class-level [MapTypes] shorthand for simple mapping declarations
  • Add inline MappingBuilder.Configure() / AddMappings() registration with compile-time lambda parsing
  • Add enum auto-detection for configuration-based mappings (automatic switch expression generation)
  • Add new annotations: MappingConfigurationAttribute, MapConfigPropertyAttribute, MapConfigIgnoreAttribute,
    MapConfigOptionsAttribute, MapTypesAttribute, MappingBuilder
  • Add diagnostics ATCMCF001-014, ATCMAP005-006, ATCMAP010-011, ATCENUM006 for configuration mapping validation
  • Add MappingOnlyConfiguration sample (CRM external type mapping scenario)
  • Add MappingCombinedConfiguration sample (mixed attribute + config + inline mapping)

⚡ Performance

  • Migrate DependencyRegistration, OptionsBinding, and EnumMapping generators to ForAttributeWithMetadataName for optimal
    incremental caching
  • Replace ToDisplayString() attribute comparisons with MetadataName checks across all 6 generators
  • Pre-compile regex patterns in FilterRules and use HashSet for interface exclusion
  • Fix string allocation in PropertyNameUtility using range operator
  • Add symbol-based HashSet<string> deduplication for partial class handling across all generators

♻️ Refactoring

  • Extract shared MappingTypeAnalyzer (9 duplicate methods consolidated from ObjectMapping/MappingConfiguration)
  • Extract TypeNameSanitizer for safe generic type name handling in generated identifiers
  • Extract shared EnumMappingHelper for enum mapping code generation pipeline

✅ Tests

  • Add comprehensive MappingConfiguration test suite (12 test files: basic, property, enum, conflict, advanced, diagnostic, edge
    case, assembly, class-level, inline, error tests)
  • Add extended EnumMapping tests (flags, special cases, bidirectional)
  • Add DependencyRegistration runtime filter and decorator tests
  • Add ObjectMapping error handling and UpdateTarget tests
  • Add AnnotationConstants Atc-specific attribute tests
  • Add integration tests that verify all sample projects build successfully

📝 Documentation

  • Migrate all 18 docs/*.md files to GitHub wiki
  • Update README.md to reference wiki instead of docs/
  • Update CLAUDE.md with MappingConfiguration generator documentation

🔧 Configuration

  • Add sample .editorconfig for sample projects
  • Update Directory.Build.props and project references for new sample projects

davidkallesen and others added 7 commits March 12, 2026 21:59
- Add MappingConfigurationGenerator with mapper class pattern, assembly-level
  MapTypes, class-level MapTypes, and inline MappingBuilder registration
- Add new attributes: MappingConfiguration, MapConfigProperty, MapConfigIgnore,
  MapConfigOptions, MapTypes, MappingBuilder
- Add enum auto-detection for configuration-based mappings
- Add diagnostics ATCMCF001-014 and ATCMAP005-006

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add MappingOnlyConfiguration sample (CRM external type mapping)
- Add MappingCombinedConfiguration sample (mixed attribute + config mapping)
- Update solution file and project references

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove all 18 docs/*.md files (migrated to GitHub wiki)
- Update README.md to reference wiki instead of docs/
- Update CLAUDE.md with MappingConfiguration documentation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ataName

- Replace ToDisplayString() attribute comparisons with MetadataName checks across all 6 generators
- Migrate ObjectMapping, EnumMapping, DependencyRegistration, and OptionsBinding to ForAttributeWithMetadataName
- Pre-compile regex patterns in FilterRules and use HashSet for interface exclusion
- Fix string allocation in PropertyNameUtility using range operator

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…lpers

- Extract 9 duplicate methods from ObjectMapping/MappingConfiguration into MappingTypeAnalyzer
- Add TypeNameSanitizer for safe generic type name handling in generated identifiers
- Add new diagnostic IDs ATCENUM006 and ATCMAP011

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add Atc-specific attribute tests for AnnotationConstantsGenerator
- Add extended EnumMapping tests (flags, special cases, bidirectional)
- Add MappingConfiguration error and property mapping tests
- Add ObjectMapping error handling and UpdateTarget tests
- Add DependencyRegistration runtime filter and decorator tests
- Add integration tests that build sample projects

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@davidkallesen
davidkallesen merged commit 6aaccf3 into main Mar 13, 2026
4 checks passed
@davidkallesen
davidkallesen deleted the feature/Mapping-Configuration branch March 13, 2026 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant