Skip to content

Refactor expression extensions; fix typos and errors#199

Merged
BlaiseD merged 5 commits intomasterfrom
Cleanup
Feb 24, 2026
Merged

Refactor expression extensions; fix typos and errors#199
BlaiseD merged 5 commits intomasterfrom
Cleanup

Conversation

@BlaiseD
Copy link
Member

@BlaiseD BlaiseD commented Feb 24, 2026

  • Consolidated all expression extension methods into ExpressionExtensions.cs; deleted VisitorExtensions.cs.
  • Added ExpressionHelpers.cs for member access and parameter replacement helpers.
  • Fixed resource typos ("deledate" → "delegate", "rempa" → "map").
  • Added new error message for invalid type mappings.
  • Updated TypeMappingsManager to throw on mismatched Expression<> types and always add type mappings for argument pairs.
  • Cleaned up XpressionMapperVisitor.cs, fixed VisitParameter bug, and removed unused ConvertTypesIfNecessary.
  • Updated unit tests for corrected error messages.
  • Improves code organization, error clarity, and maintainability.

- Consolidated all expression extension methods into ExpressionExtensions.cs; deleted VisitorExtensions.cs.
- Added ExpressionHelpers.cs for member access and parameter replacement helpers.
- Fixed resource typos ("deledate" → "delegate", "rempa" → "map").
- Added new error message for invalid type mappings.
- Updated TypeMappingsManager to throw on mismatched Expression<> types and always add type mappings for argument pairs.
- Cleaned up XpressionMapperVisitor.cs, fixed VisitParameter bug, and removed unused ConvertTypesIfNecessary.
- Updated unit tests for corrected error messages.
- Improves code organization, error clarity, and maintainability.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the expression extension methods by consolidating VisitorExtensions.cs into ExpressionExtensions.cs and extracting non-extension helper methods into a new ExpressionHelpers.cs file. It also corrects several typos in resource strings and error messages, fixes a bug in XpressionMapperVisitor.VisitParameter, removes unused code, and adds validation logic to TypeMappingsManager to ensure Expression<> type pairs are properly matched.

Changes:

  • Consolidated expression extension methods from VisitorExtensions.cs into ExpressionExtensions.cs and deleted VisitorExtensions.cs
  • Created ExpressionHelpers.cs for helper methods that are not extension methods
  • Fixed typos in resource files: "deledate" → "delegate", "rempa" → "map"
  • Added validation in TypeMappingsManager to throw ArgumentException when source is Expression but dest is not Expression
  • Fixed VisitParameter bug using correct KeyValuePair generic type
  • Removed unused ConvertTypesIfNecessary method and unnecessary using directives

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/AutoMapper.Extensions.ExpressionMapping.UnitTests/TypeMappingsManagerTest.cs Updated test assertions to match corrected error message ("delegate" instead of "deledate")
src/AutoMapper.Extensions.ExpressionMapping/XpressionMapperVisitor.cs Removed unused imports, fixed VisitParameter generic type bug, and deleted unused ConvertTypesIfNecessary method
src/AutoMapper.Extensions.ExpressionMapping/TypeMappingsManager.cs Added validation for Expression<> type pairs and simplified DoAddTypeMappings/DoAddTypeMappingsFromDelegates methods
src/AutoMapper.Extensions.ExpressionMapping/Properties/Resources.resx Fixed typos and added new error message for invalid type mappings
src/AutoMapper.Extensions.ExpressionMapping/Properties/Resources.Designer.cs Updated generated code for corrected resource strings
src/AutoMapper.Extensions.ExpressionMapping/MapperExtensions.cs Updated to use corrected resource key cantMapExpression
src/AutoMapper.Extensions.ExpressionMapping/Extensions/VisitorExtensions.cs Deleted file - methods moved to ExpressionExtensions.cs and ExpressionHelpers.cs
src/AutoMapper.Extensions.ExpressionMapping/ExpressionHelpers.cs New file containing helper methods (MemberAccesses, ReplaceParameters, Replace) that are not extension methods
src/AutoMapper.Extensions.ExpressionMapping/ExpressionExtensions.cs Consolidated all expression extension methods from VisitorExtensions.cs
Files not reviewed (1)
  • src/AutoMapper.Extensions.ExpressionMapping/Properties/Resources.Designer.cs: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI commented Feb 24, 2026

@BlaiseD I've opened a new pull request, #200, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 4 commits February 24, 2026 13:46
* Initial plan

* Add test for Expression source with non-Expression destination validation

Co-authored-by: BlaiseD <7595209+BlaiseD@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: BlaiseD <7595209+BlaiseD@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Corrected "Invalis type mappings" to "Invalid type mappings" in the assertion for AddTypeMapping_ExpressionSourceNonExpressionDest_ThrowsArgumentExcep test to ensure accurate exception message validation.
Corrected "Invalis" to "Invalid" in resource string summaries and XML comments. Also fixed "destinationTyp;" to "destinationType" in resource comments for clarity. No functional changes made.
@BlaiseD BlaiseD merged commit c77eb86 into master Feb 24, 2026
7 checks passed
@BlaiseD BlaiseD deleted the Cleanup branch February 24, 2026 19:00
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.

3 participants