Improved LINQ method generation for enumerable properties#60
Merged
mrtaikandi merged 1 commit intomainfrom May 22, 2025
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces enhancements to the mapping functionality, particularly focusing on handling primitive types and improving LINQ-based mapping for enumerable properties. It also includes minor refactoring for code clarity and additional test cases to ensure the correctness of the changes.
Enhancements to Primitive Type Handling:
IsPrimitiveTypemethod inSymbolExtensions.csto includeSystem.Guidas a primitive type and refactored logic for clarity. ([[1]](https://github.com/mrtaikandi/MapTo/pull/60/files#diff-ba40976ead2ddf1740a1927cac5efb74a50988e800b9bc1948f12d2a6de7fdd9L56-R63),[[2]](https://github.com/mrtaikandi/MapTo/pull/60/files#diff-ba40976ead2ddf1740a1927cac5efb74a50988e800b9bc1948f12d2a6de7fdd9L69-R77))ElementTypeIsPrimitiveproperty toTypeMappingand updated its initialization to determine if the element type of a collection is primitive. ([[1]](https://github.com/mrtaikandi/MapTo/pull/60/files#diff-3143b6427db7c84654129c68218fa169962faf46f10eda3e209221dcedeaebebR15),[[2]](https://github.com/mrtaikandi/MapTo/pull/60/files#diff-3143b6427db7c84654129c68218fa169962faf46f10eda3e209221dcedeaebebR66))Improvements to LINQ-based Mapping:
ArrayPropertyMappingGenerator.csandGenericEnumerablePropertyMappingGenerator.csto use LINQ methods directly when both source and target element types are primitive. ([[1]](https://github.com/mrtaikandi/MapTo/pull/60/files#diff-20a20ade2e68d6800c40d3eac7bf1ab7fadf37ef6cb4bad9517f030eb82bb748R186),[[2]](https://github.com/mrtaikandi/MapTo/pull/60/files#diff-20a20ade2e68d6800c40d3eac7bf1ab7fadf37ef6cb4bad9517f030eb82bb748R203),[[3]](https://github.com/mrtaikandi/MapTo/pull/60/files#diff-6d173185170641afdd1b796b163083c02a5c9e2d4220b5b448f11abad3df8a08R75-R84))TypeConverterPropertyMappingGenerator.csto handle primitive types efficiently in mapping scenarios. ([src/MapTo/Generators/Properties/TypeConverterPropertyMappingGenerator.csR58-R73](https://github.com/mrtaikandi/MapTo/pull/60/files#diff-a6dcad795c583752ce7a70894220007a4fcc67ab702983cf888500106180cc22R58-R73))Refactoring and Code Simplification:
GetElementTypelogic inSymbolExtensions.csto return the named type symbol directly. ([src/MapTo/CodeAnalysis/SymbolExtensions.csL185-R192](https://github.com/mrtaikandi/MapTo/pull/60/files#diff-ba40976ead2ddf1740a1927cac5efb74a50988e800b9bc1948f12d2a6de7fdd9L185-R192))WriteIfwithWriteLineIfin multiple generators for better readability and consistency. ([[1]](https://github.com/mrtaikandi/MapTo/pull/60/files#diff-20a20ade2e68d6800c40d3eac7bf1ab7fadf37ef6cb4bad9517f030eb82bb748L175-R175),[[2]](https://github.com/mrtaikandi/MapTo/pull/60/files#diff-6d173185170641afdd1b796b163083c02a5c9e2d4220b5b448f11abad3df8a08L63-R63))Test Coverage Enhancements:
ToList,ToArray, etc.). ([test/MapTo.Tests/MapFromCollectionTests.csR577-R674](https://github.com/mrtaikandi/MapTo/pull/60/files#diff-365ce719a1c6eefbbfd8ad82140bbc63f781fe8172aeb7797abe4ec9a2938692R577-R674))[[1]](https://github.com/mrtaikandi/MapTo/pull/60/files#diff-365ce719a1c6eefbbfd8ad82140bbc63f781fe8172aeb7797abe4ec9a2938692L79-R80),[[2]](https://github.com/mrtaikandi/MapTo/pull/60/files#diff-365ce719a1c6eefbbfd8ad82140bbc63f781fe8172aeb7797abe4ec9a2938692L202-R205))Bug Fixes:
EnumerableTypeConverterResolver.csto handle cases where the element type is primitive or has aMapFromattribute. ([[1]](https://github.com/mrtaikandi/MapTo/pull/60/files#diff-4759406929debd1363acffc70084fccc1e8befdf7e668d2627c41be99de62ef8R24-R43),[[2]](https://github.com/mrtaikandi/MapTo/pull/60/files#diff-4759406929debd1363acffc70084fccc1e8befdf7e668d2627c41be99de62ef8L41-R53))