Skip to content

#299 MappaDependencyInjectionAttribute - #302

Merged
sanelli merged 11 commits into
mainfrom
299-mappadependencyinjectionattribute
Aug 1, 2026
Merged

#299 MappaDependencyInjectionAttribute#302
sanelli merged 11 commits into
mainfrom
299-mappadependencyinjectionattribute

Conversation

@sanelli

@sanelli sanelli commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add [MappaDependencyInjection] on a separate partial registrar class; the generator emits an IServiceCollection registration method for all same-assembly [Mappa] mappers.
  • Configurable method name, extension vs instance, accessibility, service lifetime, InjectInterfaces (ClassOnly / InterfaceOnly / InterfaceAndClass), and IgnoreType.
  • Diagnostics MP00070MP00073 (non-partial, attribute conflict, no eligible interfaces, static mapper skipped); samples, AOT runner, and docs included.
  • Version bumped to 10.2.0-alpha.48.

Test plan

  • Generator integration tests (happy path + diagnostics including MP00073)
  • Samples tests for RegisterMappaSamples
  • AOT smoke runner for DI registrar
  • .\Scripts\RunTestsAndReportCoverage.ps1 (line/branch slightly below step-1 baseline — see coverage note)

Coverage note

Final coverage vs issue baseline (98.4% / 90.6% / 100%): 98.3% / 90.3% / 100%. Remaining DI gaps are mostly defensive paths (GetDeclaredSymbol / null attribute data, inject-partial fallback) and shared AttributeDataExtensions helpers.

sanelli and others added 11 commits August 1, 2026 21:28
Introduce the public API for DI registrar generation (attribute, inject/lifetime/accessibility enums), unit tests, README entry, and alpha.45 package bump so the generator can consume the new surface.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add the incremental DI pipeline, assembly mapper discovery, registration source emission, and MP00070-MP00072 diagnostics for partial/conflict/interface edge cases.

Co-authored-by: Cursor <cursoragent@cursor.com>
Cover DI registration generation and MP00070-72 diagnostics with syntax-tree assertions, attribute parsing unit tests, and a DependencyInjection.Abstractions reference for BuildCompilation.

Co-authored-by: Cursor <cursoragent@cursor.com>
Cover block/global namespaces, Private/Protected/ProtectedInternal accessibility, and nested [Mappa] mapper discovery.

Co-authored-by: Cursor <cursoragent@cursor.com>
Rebuild packages so Samples consume the updated Generator.

Co-authored-by: Cursor <cursoragent@cursor.com>
Skip static [Mappa] types during dependency injection discovery, emit XML docs on the generated registration method, and report MP00073 when a static mapper is skipped.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add a registrar sample with RegisterMappaSamples, a dedicated mapper, DI package reference, and unit tests that resolve registered mappers. Suppress MP00073 for intentional static sample mappers.

Co-authored-by: Cursor <cursoragent@cursor.com>
Rebuild packages so Samples consume the updated Generator with MP00073.

Co-authored-by: Cursor <cursoragent@cursor.com>
Place StaticMapperReportsWarningAndIsSkippedFromRegistration alongside the other MappaDependencyInjection diagnostic tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
Exercise RegisterMappaSamples under Native AOT by resolving MappaDependencyInjectionMapper from the service provider.

Co-authored-by: Cursor <cursoragent@cursor.com>
Update attributes, algorithm, features, tutorial, and package READMEs for dependency injection registration and MP00070-73.

Co-authored-by: Cursor <cursoragent@cursor.com>
@sanelli sanelli linked an issue Aug 1, 2026 that may be closed by this pull request
@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown

Code coverage

Compared against the latest published coverage history from the code coverage gist.

Metric Baseline PR Δ Trend
Line 98.4% 98.3% -0.1
Branch 90.6% 90.3% -0.3
Method 100% 100% 0 =

No coverage metric dropped by more than 1 percentage point(s) versus baseline.

Benchmarks

AutoMapper is the BenchmarkDotNet ratio baseline. Absolute values are mean time in nanoseconds and allocated bytes. Ratio columns are competitor / Mappa as a percentage (n/a when either side is missing or Mappa is zero).

Benchmark Automapper Mean (ns) Automapper Allocated (B) Mapster Mean (ns) Mapster Allocated (B) Mapperly Mean (ns) Mapperly Allocated (B) Mappa Mean (ns) Mappa Allocated (B) Automapper/Mappa Time Automapper/Mappa Alloc Mapperly/Mappa Time Mapperly/Mappa Alloc Mapster/Mappa Time Mapster/Mappa Alloc
ArrayToListBenchmark 389150 592056.32 247810 648058.88 17020 128051.2 16930 128051.2 2298.6% 462.4% 100.5% 100% 1463.7% 506.1%
DictionaryBenchmark 399930 615014.4 282600 742277.12 31540 151019.52 39620 222218.24 1009.4% 276.8% 79.6% 68% 713.3% 334%
FastListToArrayBenchmark 387940 592025.6 242150 648028.16 16980 128020.48 19030 128020.48 2038.6% 462.4% 89.2% 100% 1272.5% 506.2%
IQueryableProjectionBenchmark 555700 67973.12 538000 67205.12 549900 69150.72 547900 69150.72 101.4% 98.3% 100.4% 100% 98.2% 97.2%
ListToArrayBenchmark 392020 592025.6 244740 648028.16 16890 128020.48 18050 128020.48 2171.9% 462.4% 93.6% 100% 1355.9% 506.2%
NestedDtoBenchmark 450010 742768.64 306160 789555.2 36060 149401.6 33090 157900.8 1360% 470.4% 109% 94.6% 925.2% 500%

@sanelli
sanelli merged commit 2fd44b5 into main Aug 1, 2026
1 check passed
@sanelli
sanelli deleted the 299-mappadependencyinjectionattribute branch August 1, 2026 21:45
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.

MappaDependencyInjectionAttribute

1 participant