Skip to content

Refactored FluentMapping into separate assembly#991

Merged
michelebastione merged 3 commits into
mini-software:masterfrom
michelebastione:fluent-mapping-assembly
Jul 23, 2026
Merged

Refactored FluentMapping into separate assembly#991
michelebastione merged 3 commits into
mini-software:masterfrom
michelebastione:fluent-mapping-assembly

Conversation

@michelebastione

@michelebastione michelebastione commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

This makes it easier to mantain and it also makes the main MiniExcel.OpenXml assembly smaller for the users who don't care for the fluent mapping.

…assembly

This makes the main MiniExcel.OpenXml assembly smaller for the users who don't care for the fluent mapping
Manually added latest version of the package where NPOI brought in a vulnerable one
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Fluent OpenXML Mapping

Layer / File(s) Summary
Mapping configuration and compilation
src/MiniExcel.OpenXml.FluentMapping/Configuration/*, src/MiniExcel.OpenXml.FluentMapping/Helpers/*, src/MiniExcel.OpenXml.FluentMapping/MappingCompiler.cs, src/MiniExcel.OpenXml.FluentMapping/MappingRegistry.cs, src/MiniExcel.OpenXml.FluentMapping/CompiledMapping.cs
Adds fluent property and collection mapping contracts, nested metadata, optimized handlers, compilation, conversion, and registry caching.
Mapped workbook streaming I/O
src/MiniExcel.OpenXml.FluentMapping/MappingWriter.cs, src/MiniExcel.OpenXml.FluentMapping/MappingCellStream.cs, src/MiniExcel.OpenXml.FluentMapping/Api/MappingExporter.cs, src/MiniExcel.OpenXml.FluentMapping/Api/MappingImporter.cs, src/MiniExcel.OpenXml.FluentMapping/OpenXmlMappingReader.cs, src/MiniExcel.OpenXml/Reader/OpenXmlReader.cs
Adds streaming mapped export and import paths with file and stream overloads and expanded reader subclass access.
Template filling flow
src/MiniExcel.OpenXml.FluentMapping/Api/MappingTemplater.cs, src/MiniExcel.OpenXml.FluentMapping/MappingTemplateApplicator.cs, src/MiniExcel.OpenXml.FluentMapping/MappingTemplateProcessor.cs
Adds template filling overloads, obsolete forwarding APIs, XML preservation, and mapped row or cell insertion.
Project wiring and provider access
src/MiniExcel.OpenXml.FluentMapping/Api/ProviderExtensions.cs, src/MiniExcel.OpenXml.FluentMapping/MiniExcel.OpenXml.FluentMapping.csproj, src/MiniExcel/MiniExcel.csproj, src/MiniExcel.OpenXml/MiniExcel.OpenXml.csproj, tests/MiniExcel.OpenXml.Tests/MiniExcel.OpenXml.Tests.csproj, MiniExcel.slnx, benchmarks/MiniExcel.Benchmarks/MiniExcel.Benchmarks.csproj
Adds provider factories, project references, shared project content, solution entries, and package version updates.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant MappingRegistry
  participant MappingExporter
  participant MappingWriter
  participant OpenXmlWriter
  Caller->>MappingRegistry: Configure<T>
  MappingRegistry-->>Caller: compiled mapping
  Caller->>MappingExporter: ExportAsync<T>
  MappingExporter->>MappingWriter: SaveAsAsync
  MappingWriter->>OpenXmlWriter: write mapped worksheet
  OpenXmlWriter-->>Caller: export result
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.18% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: moving FluentMapping into a separate assembly.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/MiniExcel.OpenXml.FluentMapping/OpenXmlMappingReader.cs (1)

54-55: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Handle cells without an r attribute.

Line 54 forces withoutCr to false; when aR is absent, the inherited parser retains the prior column index, so every cell in that row overwrites the same MappedRow slot. Detect this mode as OpenXmlReader does, or switch to sequential indexing when a cell reference is missing.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/MiniExcel.OpenXml.FluentMapping/OpenXmlMappingReader.cs` around lines 54
- 55, Update the cell-mapping logic in OpenXmlMappingReader to detect when a
cell lacks its r attribute and enable the withoutCr/sequential-index path
instead of always setting withoutCr to false. Match OpenXmlReader’s detection
behavior or otherwise advance column indexes sequentially, while preserving
referenced-cell handling.
🧹 Nitpick comments (1)
src/MiniExcel.OpenXml.FluentMapping/MappingTemplateApplicator.cs (1)

22-34: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Buffered template MemoryStream is never disposed.

When templateStream isn't seekable it's copied into memStream, which is reassigned to templateStream but never disposed. It's a MemoryStream (no unmanaged handles), so impact is minimal, but a using/explicit dispose keeps lifetimes clean.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/MiniExcel.OpenXml.FluentMapping/MappingTemplateApplicator.cs` around
lines 22 - 34, The non-seekable stream handling in MappingTemplateApplicator
must dispose the buffered MemoryStream after template processing completes.
Track the created stream separately or scope it with disposal while preserving
templateStream usage throughout the operation, and ensure disposal occurs even
when processing fails.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/MiniExcel.OpenXml.FluentMapping/Configuration/IMappingConfiguration.cs`:
- Line 6: The collection mapping API must prevent an item mapping type from
disagreeing with the collection’s actual element type. Update
src/MiniExcel.OpenXml.FluentMapping/Configuration/IMappingConfiguration.cs#L6-L6
and
src/MiniExcel.OpenXml.FluentMapping/Configuration/ICollectionMappingBuilder.cs#L9-L9
to expose or constrain an element-typed contract so unrelated types cannot be
selected; additionally update CollectionMappingBuilder configuration logic at
src/MiniExcel.OpenXml.FluentMapping/Configuration/CollectionMappingBuilder.cs#L43-L52
to inspect known generic collection element types and reject mismatches during
configuration.

In `@src/MiniExcel.OpenXml.FluentMapping/Configuration/PropertyMappingBuilder.cs`:
- Around line 25-26: Update ToCell in
src/MiniExcel.OpenXml.FluentMapping/Configuration/PropertyMappingBuilder.cs
(lines 25-26) to validate parsed Excel coordinates against valid column and row
bounds, rejecting values such as A0, XFE1, and A1048577. Apply the same
bounds-aware validation to StartAt in
src/MiniExcel.OpenXml.FluentMapping/Configuration/CollectionMappingBuilder.cs
(lines 27-28), preferably through one shared validation helper.

In `@src/MiniExcel.OpenXml.FluentMapping/Helpers/ConversionHelper.cs`:
- Around line 13-19: Update ConversionHelper.ConvertValue to handle a null value
before calling value.GetType() or evaluating the assignability fast path. Return
the appropriate null result for nullable/reference targets while preserving the
existing conversion flow for non-null inputs.

In `@src/MiniExcel.OpenXml.FluentMapping/MappingCompiler.cs`:
- Line 56: Validate the boolean result of TryParseCellReference for
prop.CellAddress in the mapping compilation flow, and surface a configuration
error when parsing fails instead of using default cellCol/cellRow values. Apply
the same validation to the corresponding TryParseCellReference call for
coll.StartCell, preserving normal mapping when both references parse
successfully.

---

Outside diff comments:
In `@src/MiniExcel.OpenXml.FluentMapping/OpenXmlMappingReader.cs`:
- Around line 54-55: Update the cell-mapping logic in OpenXmlMappingReader to
detect when a cell lacks its r attribute and enable the
withoutCr/sequential-index path instead of always setting withoutCr to false.
Match OpenXmlReader’s detection behavior or otherwise advance column indexes
sequentially, while preserving referenced-cell handling.

---

Nitpick comments:
In `@src/MiniExcel.OpenXml.FluentMapping/MappingTemplateApplicator.cs`:
- Around line 22-34: The non-seekable stream handling in
MappingTemplateApplicator must dispose the buffered MemoryStream after template
processing completes. Track the created stream separately or scope it with
disposal while preserving templateStream usage throughout the operation, and
ensure disposal occurs even when processing fails.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f4eb3bfd-e0e8-41fb-a589-002dd4414469

📥 Commits

Reviewing files that changed from the base of the PR and between b5613e5 and 5cea644.

📒 Files selected for processing (32)
  • MiniExcel.slnx
  • benchmarks/MiniExcel.Benchmarks/MiniExcel.Benchmarks.csproj
  • src/MiniExcel.OpenXml.FluentMapping/Api/MappingExporter.cs
  • src/MiniExcel.OpenXml.FluentMapping/Api/MappingImporter.cs
  • src/MiniExcel.OpenXml.FluentMapping/Api/MappingTemplater.cs
  • src/MiniExcel.OpenXml.FluentMapping/Api/ProviderExtensions.cs
  • src/MiniExcel.OpenXml.FluentMapping/CompiledMapping.cs
  • src/MiniExcel.OpenXml.FluentMapping/Configuration/CollectionMappingBuilder.cs
  • src/MiniExcel.OpenXml.FluentMapping/Configuration/ICollectionMappingBuilder.cs
  • src/MiniExcel.OpenXml.FluentMapping/Configuration/IMappingConfiguration.cs
  • src/MiniExcel.OpenXml.FluentMapping/Configuration/IPropertyMappingBuilder.cs
  • src/MiniExcel.OpenXml.FluentMapping/Configuration/MappingConfiguration.cs
  • src/MiniExcel.OpenXml.FluentMapping/Configuration/PropertyMappingBuilder.cs
  • src/MiniExcel.OpenXml.FluentMapping/GlobalUsings.cs
  • src/MiniExcel.OpenXml.FluentMapping/Helpers/ConversionHelper.cs
  • src/MiniExcel.OpenXml.FluentMapping/Helpers/MappingMetadataExtractor.cs
  • src/MiniExcel.OpenXml.FluentMapping/MappedRow.cs
  • src/MiniExcel.OpenXml.FluentMapping/MappingCellStream.cs
  • src/MiniExcel.OpenXml.FluentMapping/MappingCellStreamAdapter.cs
  • src/MiniExcel.OpenXml.FluentMapping/MappingCompiler.cs
  • src/MiniExcel.OpenXml.FluentMapping/MappingReader.cs
  • src/MiniExcel.OpenXml.FluentMapping/MappingRegistry.cs
  • src/MiniExcel.OpenXml.FluentMapping/MappingTemplateApplicator.cs
  • src/MiniExcel.OpenXml.FluentMapping/MappingTemplateProcessor.cs
  • src/MiniExcel.OpenXml.FluentMapping/MappingWriter.cs
  • src/MiniExcel.OpenXml.FluentMapping/MiniExcel.OpenXml.FluentMapping.csproj
  • src/MiniExcel.OpenXml.FluentMapping/NestedMappingInfo.cs
  • src/MiniExcel.OpenXml.FluentMapping/OpenXmlMappingReader.cs
  • src/MiniExcel.OpenXml/MiniExcel.OpenXml.csproj
  • src/MiniExcel.OpenXml/Reader/OpenXmlReader.cs
  • src/MiniExcel/MiniExcel.csproj
  • tests/MiniExcel.OpenXml.Tests/MiniExcel.OpenXml.Tests.csproj

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/MiniExcel.OpenXml.FluentMapping/OpenXmlMappingReader.cs (1)

54-55: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Handle cells without an r attribute.

Line 54 forces withoutCr to false; when aR is absent, the inherited parser retains the prior column index, so every cell in that row overwrites the same MappedRow slot. Detect this mode as OpenXmlReader does, or switch to sequential indexing when a cell reference is missing.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/MiniExcel.OpenXml.FluentMapping/OpenXmlMappingReader.cs` around lines 54
- 55, Update the cell-mapping logic in OpenXmlMappingReader to detect when a
cell lacks its r attribute and enable the withoutCr/sequential-index path
instead of always setting withoutCr to false. Match OpenXmlReader’s detection
behavior or otherwise advance column indexes sequentially, while preserving
referenced-cell handling.
🧹 Nitpick comments (1)
src/MiniExcel.OpenXml.FluentMapping/MappingTemplateApplicator.cs (1)

22-34: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Buffered template MemoryStream is never disposed.

When templateStream isn't seekable it's copied into memStream, which is reassigned to templateStream but never disposed. It's a MemoryStream (no unmanaged handles), so impact is minimal, but a using/explicit dispose keeps lifetimes clean.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/MiniExcel.OpenXml.FluentMapping/MappingTemplateApplicator.cs` around
lines 22 - 34, The non-seekable stream handling in MappingTemplateApplicator
must dispose the buffered MemoryStream after template processing completes.
Track the created stream separately or scope it with disposal while preserving
templateStream usage throughout the operation, and ensure disposal occurs even
when processing fails.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/MiniExcel.OpenXml.FluentMapping/Configuration/IMappingConfiguration.cs`:
- Line 6: The collection mapping API must prevent an item mapping type from
disagreeing with the collection’s actual element type. Update
src/MiniExcel.OpenXml.FluentMapping/Configuration/IMappingConfiguration.cs#L6-L6
and
src/MiniExcel.OpenXml.FluentMapping/Configuration/ICollectionMappingBuilder.cs#L9-L9
to expose or constrain an element-typed contract so unrelated types cannot be
selected; additionally update CollectionMappingBuilder configuration logic at
src/MiniExcel.OpenXml.FluentMapping/Configuration/CollectionMappingBuilder.cs#L43-L52
to inspect known generic collection element types and reject mismatches during
configuration.

In `@src/MiniExcel.OpenXml.FluentMapping/Configuration/PropertyMappingBuilder.cs`:
- Around line 25-26: Update ToCell in
src/MiniExcel.OpenXml.FluentMapping/Configuration/PropertyMappingBuilder.cs
(lines 25-26) to validate parsed Excel coordinates against valid column and row
bounds, rejecting values such as A0, XFE1, and A1048577. Apply the same
bounds-aware validation to StartAt in
src/MiniExcel.OpenXml.FluentMapping/Configuration/CollectionMappingBuilder.cs
(lines 27-28), preferably through one shared validation helper.

In `@src/MiniExcel.OpenXml.FluentMapping/Helpers/ConversionHelper.cs`:
- Around line 13-19: Update ConversionHelper.ConvertValue to handle a null value
before calling value.GetType() or evaluating the assignability fast path. Return
the appropriate null result for nullable/reference targets while preserving the
existing conversion flow for non-null inputs.

In `@src/MiniExcel.OpenXml.FluentMapping/MappingCompiler.cs`:
- Line 56: Validate the boolean result of TryParseCellReference for
prop.CellAddress in the mapping compilation flow, and surface a configuration
error when parsing fails instead of using default cellCol/cellRow values. Apply
the same validation to the corresponding TryParseCellReference call for
coll.StartCell, preserving normal mapping when both references parse
successfully.

---

Outside diff comments:
In `@src/MiniExcel.OpenXml.FluentMapping/OpenXmlMappingReader.cs`:
- Around line 54-55: Update the cell-mapping logic in OpenXmlMappingReader to
detect when a cell lacks its r attribute and enable the
withoutCr/sequential-index path instead of always setting withoutCr to false.
Match OpenXmlReader’s detection behavior or otherwise advance column indexes
sequentially, while preserving referenced-cell handling.

---

Nitpick comments:
In `@src/MiniExcel.OpenXml.FluentMapping/MappingTemplateApplicator.cs`:
- Around line 22-34: The non-seekable stream handling in
MappingTemplateApplicator must dispose the buffered MemoryStream after template
processing completes. Track the created stream separately or scope it with
disposal while preserving templateStream usage throughout the operation, and
ensure disposal occurs even when processing fails.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f4eb3bfd-e0e8-41fb-a589-002dd4414469

📥 Commits

Reviewing files that changed from the base of the PR and between b5613e5 and 5cea644.

📒 Files selected for processing (32)
  • MiniExcel.slnx
  • benchmarks/MiniExcel.Benchmarks/MiniExcel.Benchmarks.csproj
  • src/MiniExcel.OpenXml.FluentMapping/Api/MappingExporter.cs
  • src/MiniExcel.OpenXml.FluentMapping/Api/MappingImporter.cs
  • src/MiniExcel.OpenXml.FluentMapping/Api/MappingTemplater.cs
  • src/MiniExcel.OpenXml.FluentMapping/Api/ProviderExtensions.cs
  • src/MiniExcel.OpenXml.FluentMapping/CompiledMapping.cs
  • src/MiniExcel.OpenXml.FluentMapping/Configuration/CollectionMappingBuilder.cs
  • src/MiniExcel.OpenXml.FluentMapping/Configuration/ICollectionMappingBuilder.cs
  • src/MiniExcel.OpenXml.FluentMapping/Configuration/IMappingConfiguration.cs
  • src/MiniExcel.OpenXml.FluentMapping/Configuration/IPropertyMappingBuilder.cs
  • src/MiniExcel.OpenXml.FluentMapping/Configuration/MappingConfiguration.cs
  • src/MiniExcel.OpenXml.FluentMapping/Configuration/PropertyMappingBuilder.cs
  • src/MiniExcel.OpenXml.FluentMapping/GlobalUsings.cs
  • src/MiniExcel.OpenXml.FluentMapping/Helpers/ConversionHelper.cs
  • src/MiniExcel.OpenXml.FluentMapping/Helpers/MappingMetadataExtractor.cs
  • src/MiniExcel.OpenXml.FluentMapping/MappedRow.cs
  • src/MiniExcel.OpenXml.FluentMapping/MappingCellStream.cs
  • src/MiniExcel.OpenXml.FluentMapping/MappingCellStreamAdapter.cs
  • src/MiniExcel.OpenXml.FluentMapping/MappingCompiler.cs
  • src/MiniExcel.OpenXml.FluentMapping/MappingReader.cs
  • src/MiniExcel.OpenXml.FluentMapping/MappingRegistry.cs
  • src/MiniExcel.OpenXml.FluentMapping/MappingTemplateApplicator.cs
  • src/MiniExcel.OpenXml.FluentMapping/MappingTemplateProcessor.cs
  • src/MiniExcel.OpenXml.FluentMapping/MappingWriter.cs
  • src/MiniExcel.OpenXml.FluentMapping/MiniExcel.OpenXml.FluentMapping.csproj
  • src/MiniExcel.OpenXml.FluentMapping/NestedMappingInfo.cs
  • src/MiniExcel.OpenXml.FluentMapping/OpenXmlMappingReader.cs
  • src/MiniExcel.OpenXml/MiniExcel.OpenXml.csproj
  • src/MiniExcel.OpenXml/Reader/OpenXmlReader.cs
  • src/MiniExcel/MiniExcel.csproj
  • tests/MiniExcel.OpenXml.Tests/MiniExcel.OpenXml.Tests.csproj
🛑 Comments failed to post (4)
src/MiniExcel.OpenXml.FluentMapping/Configuration/IMappingConfiguration.cs (1)

6-6: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Preserve or validate the collection element type. The API permits mappings such as Collection(x => x.Ints).WithItemMapping<Address>(...); the stored ItemType then disagrees with the actual collection values and fails later during mapping execution.

  • src/MiniExcel.OpenXml.FluentMapping/Configuration/IMappingConfiguration.cs#L6-L6: expose an element-typed collection mapping contract where practical.
  • src/MiniExcel.OpenXml.FluentMapping/Configuration/ICollectionMappingBuilder.cs#L9-L9: prevent callers from selecting an unrelated item type.
  • src/MiniExcel.OpenXml.FluentMapping/Configuration/CollectionMappingBuilder.cs#L43-L52: at minimum, inspect known generic collection element types and reject mismatches during configuration.
📍 Affects 3 files
  • src/MiniExcel.OpenXml.FluentMapping/Configuration/IMappingConfiguration.cs#L6-L6 (this comment)
  • src/MiniExcel.OpenXml.FluentMapping/Configuration/ICollectionMappingBuilder.cs#L9-L9
  • src/MiniExcel.OpenXml.FluentMapping/Configuration/CollectionMappingBuilder.cs#L43-L52
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/MiniExcel.OpenXml.FluentMapping/Configuration/IMappingConfiguration.cs`
at line 6, The collection mapping API must prevent an item mapping type from
disagreeing with the collection’s actual element type. Update
src/MiniExcel.OpenXml.FluentMapping/Configuration/IMappingConfiguration.cs#L6-L6
and
src/MiniExcel.OpenXml.FluentMapping/Configuration/ICollectionMappingBuilder.cs#L9-L9
to expose or constrain an element-typed contract so unrelated types cannot be
selected; additionally update CollectionMappingBuilder configuration logic at
src/MiniExcel.OpenXml.FluentMapping/Configuration/CollectionMappingBuilder.cs#L43-L52
to inspect known generic collection element types and reject mismatches during
configuration.
src/MiniExcel.OpenXml.FluentMapping/Configuration/PropertyMappingBuilder.cs (1)

25-26: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Reject out-of-range Excel coordinates. Both regexes accept invalid addresses such as A0, XFE1, and A1048577, allowing invalid mappings to compile and fail or misaddress cells later.

  • src/MiniExcel.OpenXml.FluentMapping/Configuration/PropertyMappingBuilder.cs#L25-L26: validate row and column bounds in ToCell.
  • src/MiniExcel.OpenXml.FluentMapping/Configuration/CollectionMappingBuilder.cs#L27-L28: apply the same bounds-aware validation in StartAt, ideally via one shared helper.
📍 Affects 2 files
  • src/MiniExcel.OpenXml.FluentMapping/Configuration/PropertyMappingBuilder.cs#L25-L26 (this comment)
  • src/MiniExcel.OpenXml.FluentMapping/Configuration/CollectionMappingBuilder.cs#L27-L28
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/MiniExcel.OpenXml.FluentMapping/Configuration/PropertyMappingBuilder.cs`
around lines 25 - 26, Update ToCell in
src/MiniExcel.OpenXml.FluentMapping/Configuration/PropertyMappingBuilder.cs
(lines 25-26) to validate parsed Excel coordinates against valid column and row
bounds, rejecting values such as A0, XFE1, and A1048577. Apply the same
bounds-aware validation to StartAt in
src/MiniExcel.OpenXml.FluentMapping/Configuration/CollectionMappingBuilder.cs
(lines 27-28), preferably through one shared validation helper.
src/MiniExcel.OpenXml.FluentMapping/Helpers/ConversionHelper.cs (1)

13-19: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -nP -C3 'CollectionItemConverter|ConvertValue\s*\(' src/MiniExcel.OpenXml.FluentMapping

Repository: mini-software/MiniExcel

Length of output: 5831


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== MappingReader around converter call ==\n'
sed -n '250,320p' src/MiniExcel.OpenXml.FluentMapping/MappingReader.cs

printf '\n== MappingCompiler around precompiled converter ==\n'
sed -n '730,760p' src/MiniExcel.OpenXml.FluentMapping/MappingCompiler.cs

printf '\n== ConversionHelper ==\n'
sed -n '1,220p' src/MiniExcel.OpenXml.FluentMapping/Helpers/ConversionHelper.cs

printf '\n== CompiledMapping CollectionItemConverter declaration ==\n'
sed -n '250,275p' src/MiniExcel.OpenXml.FluentMapping/CompiledMapping.cs

Repository: mini-software/MiniExcel

Length of output: 14660


Guard ConvertValue against null inputs. handler.CollectionItemConverter accepts object?, so a null cell can reach ConversionHelper.ConvertValue; value.GetType() then throws before the fallback path runs. Add a null check before the fast path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/MiniExcel.OpenXml.FluentMapping/Helpers/ConversionHelper.cs` around lines
13 - 19, Update ConversionHelper.ConvertValue to handle a null value before
calling value.GetType() or evaluating the assignability fast path. Return the
appropriate null result for nullable/reference targets while preserving the
existing conversion flow for non-null inputs.
src/MiniExcel.OpenXml.FluentMapping/MappingCompiler.cs (1)

56-56: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

TryParseCellReference result is ignored.

If prop.CellAddress fails to parse, cellCol/cellRow stay at their defaults (0/0) and the property is silently mapped to an invalid coordinate rather than surfacing a configuration error. Same pattern at Line 104 for coll.StartCell.

🛡️ Proposed guard
-        CellReferenceConverter.TryParseCellReference(prop.CellAddress, out int cellCol, out int cellRow);
+        if (!CellReferenceConverter.TryParseCellReference(prop.CellAddress, out int cellCol, out int cellRow))
+            throw new InvalidOperationException($"Invalid cell address '{prop.CellAddress}' for property '{propertyName}'.");
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

            if (!CellReferenceConverter.TryParseCellReference(prop.CellAddress, out int cellCol, out int cellRow))
                throw new InvalidOperationException($"Invalid cell address '{prop.CellAddress}' for property '{propertyName}'.");
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/MiniExcel.OpenXml.FluentMapping/MappingCompiler.cs` at line 56, Validate
the boolean result of TryParseCellReference for prop.CellAddress in the mapping
compilation flow, and surface a configuration error when parsing fails instead
of using default cellCol/cellRow values. Apply the same validation to the
corresponding TryParseCellReference call for coll.StartCell, preserving normal
mapping when both references parse successfully.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/MiniExcel.OpenXml.FluentMapping/Helpers/ConversionHelper.cs`:
- Around line 13-17: Update ConvertValue so a null input returns null only when
targetType supports null (nullable or reference types); for non-nullable value
types, preserve the existing default-value fallback via
Activator.CreateInstance. Add coverage verifying both nullable/reference targets
and non-nullable value targets.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 09fff427-f573-4ac7-bba9-20c623589c0d

📥 Commits

Reviewing files that changed from the base of the PR and between 5cea644 and 40ca879.

📒 Files selected for processing (3)
  • src/MiniExcel.OpenXml.FluentMapping/Helpers/ConversionHelper.cs
  • src/MiniExcel.OpenXml.FluentMapping/MappingCompiler.cs
  • src/MiniExcel.OpenXml.FluentMapping/MappingTemplateApplicator.cs
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/MiniExcel.OpenXml.FluentMapping/MappingTemplateApplicator.cs
  • src/MiniExcel.OpenXml.FluentMapping/MappingCompiler.cs

Comment thread src/MiniExcel.OpenXml.FluentMapping/Helpers/ConversionHelper.cs
@michelebastione
michelebastione force-pushed the fluent-mapping-assembly branch from 40ca879 to 2deb7e9 Compare July 23, 2026 21:46
@michelebastione
michelebastione merged commit 12a4f32 into mini-software:master Jul 23, 2026
4 checks passed
@michelebastione
michelebastione deleted the fluent-mapping-assembly branch July 23, 2026 21:50
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