Skip to content

#108 Add PreventEnumerableCount MappaSettings option - #285

Merged
sanelli merged 3 commits into
mainfrom
108-allow-preventing-using-enumerbalecountthis-t-values-when-targeting-arraysspanmemory
Jul 26, 2026
Merged

#108 Add PreventEnumerableCount MappaSettings option#285
sanelli merged 3 commits into
mainfrom
108-allow-preventing-using-enumerbalecountthis-t-values-when-targeting-arraysspanmemory

Conversation

@sanelli

@sanelli sanelli commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add MappaSettings.PreventEnumerableCount (BooleanSetting, editorconfig mappa.preventenumerablecount) so mappings from sources without Count/Length to fixed-size targets (T[], Span<T>, Memory<T>, and read-only variants) can avoid Enumerable.Count and enumerate once via a growable List<T> buffer.
  • Wire the setting through the generator settings pipeline and CollectionToCollectionMapStrategyBuilder, with integration tests (syntax-tree assertions), samples/AOT runner, and docs.
  • Version bumped to 10.2.0-alpha.24 (after Mappa and generator changes).

Test plan

  • Generator integration tests for enabled/disabled/default, Span/Memory variants, known-length sources, EnumerableConcreteType.Array, editorconfig, and class/method overrides
  • Attribute parsing unit test for PreventEnumerableCount
  • Sample unit tests + AOT project build
  • .\Scripts\RunTestsAndReportCoverage.ps1 — line/branch/method ≥ baseline (solution 98.4%/90.6%/100%; Generator branch improved to 90.6%)

Closes #108

sanelli and others added 3 commits July 26, 2026 12:57
Introduce the BooleanSetting surface and bump to 10.2.0-alpha.23 so the generator can consume it.

Co-authored-by: Cursor <cursoragent@cursor.com>
Wire the setting through Mappa.Generator, emit growable List buffers instead of Enumerable.Count for single-enumeration sources, add integration and attribute parsing tests, and bump to 10.2.0-alpha.24.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@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.

@sanelli
sanelli merged commit b42c8f8 into main Jul 26, 2026
1 check passed
@sanelli
sanelli deleted the 108-allow-preventing-using-enumerbalecountthis-t-values-when-targeting-arraysspanmemory branch July 26, 2026 12:22
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.

Allow preventing using Enumerbale.Count(this T values) when targeting arrays[]/Span/Memory

1 participant