Skip to content

#253 Object factories - #291

Merged
sanelli merged 6 commits into
mainfrom
253-object-factories
Jul 31, 2026
Merged

#253 Object factories#291
sanelli merged 6 commits into
mainfrom
253-object-factories

Conversation

@sanelli

@sanelli sanelli commented Jul 31, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add [MappaObjectFactory] so mappings can construct targets via user factory methods (mapper-local, static type, or field/property) instead of new.
  • Wire generator resolution/emission with signature tiers, MP00062–64 diagnostics, nested-target support, and projection incompatibility.
  • Add samples, AOT runner, documentation, CI AOT output silencing, and coverage-oriented tests (version 10.2.0-alpha.28).

Test plan

  • .\Scripts\RunTestsAndReportCoverage.ps1 (line/branch/method ≥ pre-change baseline)
  • Review generated syntax for factory tiers (fully produced / empty-ctor-like / parameterized)
  • Confirm MP00062 duplicate, MP00063 unresolved fallback, MP00064 projection diagnostics
  • Spot-check AOT runner and sample runtime tests

sanelli and others added 6 commits July 31, 2026 18:28
Introduce the public attribute surface for object factories and bump to 10.2.0-alpha.26 so the generator can consume it.

Co-authored-by: Cursor <cursoragent@cursor.com>
Resolve MappaObjectFactory attributes during constructor-map detection, emit factory invocations with MP00062-64 diagnostics, and add integration tests. Bump to 10.2.0-alpha.27.

Co-authored-by: Cursor <cursoragent@cursor.com>
Cover empty, context, source, source-and-context, and parameterized factory signatures across mapper-local, static-type, and field locations.

Co-authored-by: Cursor <cursoragent@cursor.com>
Mirror the five object-factory sample mappers in Native AOT and document the attribute, algorithm precedence, diagnostics MP00062-64, and README entries.

Co-authored-by: Cursor <cursoragent@cursor.com>
Redirect stdout and stderr when running the published Mappa.Samples.Aot executable from RunTestsAndReportCoverage.ps1 so PR and main workflows stay quiet.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add coverage-oriented integration tests for AssignToContext, nested factories, and resolver edge cases; simplify Enrich early-return for nested contexts; bump to 10.2.0-alpha.28.

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

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.4% 0 =
Branch 90.6% 90.6% 0 =
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 71.57 32 71456.57 194456 6593.24 38456 6556.72 38456 1.1% 0.1% 100.6% 100% 1089.8% 505.7%
DictionaryBenchmark 135470 185221.12 82620 214364.16 10270 46018.56 12080 58316.8 1121.4% 317.6% 85% 78.9% 683.9% 367.6%
FastListToArrayBenchmark n/a n/a 71892 194426.88 6195 38420.48 6823 38420.48 n/a n/a 90.8% 100% 1053.7% 506.1%
IQueryableProjectionBenchmark 611800 31784.96 583400 31016.96 596100 33105.92 596600 32983.04 102.5% 96.4% 99.9% 100.4% 97.8% 94%
ListToArrayBenchmark n/a n/a 72728 194426.88 6800 38420.48 6285 38420.48 n/a n/a 108.2% 100% 1157.2% 506.1%
ListToHashSetBenchmark 307.9 5765.12 2133.7 5765.12 2378 5806.08 2329.9 5765.12 13.2% 100% 102.1% 100.7% 91.6% 100%
NestedDtoBenchmark 122145 225320.96 86691 227471.36 6672 38942.72 6825 38942.72 1789.7% 578.6% 97.8% 100% 1270.2% 584.1%

Benchmark trends (Mappa)

Lower is better. Compared against the latest published Mappa-only rows from MAPPA-BENCHMARK-HISTORY.md.

Benchmark Measure Baseline PR Δ Trend
ArrayToListBenchmark TIME_NS 6775.41 6556.72 -218.69
ArrayToListBenchmark ALLOC_B 38456 38456 0 =
DictionaryBenchmark TIME_NS 12021 12080 +59
DictionaryBenchmark ALLOC_B 58316.8 58316.8 0 =
ListToArrayBenchmark TIME_NS 6303 6285 -18
ListToArrayBenchmark ALLOC_B 38420.48 38420.48 0 =
FastListToArrayBenchmark TIME_NS 6371 6823 +452
FastListToArrayBenchmark ALLOC_B 38420.48 38420.48 0 =
IQueryableProjectionBenchmark TIME_NS 596000 596600 +600
IQueryableProjectionBenchmark ALLOC_B 33136.64 32983.04 -153.6
NestedDtoBenchmark TIME_NS 6616 6825 +209
NestedDtoBenchmark ALLOC_B 38942.72 38942.72 0 =
ListToHashSetBenchmark TIME_NS 1936.9 2329.9 +393
ListToHashSetBenchmark ALLOC_B 5765.12 5765.12 0 =

@sanelli
sanelli merged commit 559a25f into main Jul 31, 2026
1 check passed
@sanelli
sanelli deleted the 253-object-factories branch July 31, 2026 19:42
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.

Object factories

1 participant