Skip to content

Reject non-generic collections and add tests#24917

Merged
EngincanV merged 2 commits intorel-10.1from
ObjectMappingHelper-patch
Feb 23, 2026
Merged

Reject non-generic collections and add tests#24917
EngincanV merged 2 commits intorel-10.1from
ObjectMappingHelper-patch

Conversation

@maliming
Copy link
Member

Resolve #24914

Copilot AI review requested due to automatic review settings February 22, 2026 11:40
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 pull request resolves issue #24914 by fixing an IndexOutOfRangeException that occurred when attempting to map to non-generic derived collection types (e.g., class CarDtoList : List<CarDto>). The fix adds a guard check to reject non-generic types before attempting to access their generic arguments, and includes comprehensive test coverage for various collection mapping scenarios.

Changes:

  • Added guard check in ObjectMappingHelper.IsCollectionGenericTypeInternal to reject non-generic derived collection types
  • Added comprehensive unit tests covering standard collections, arrays, interfaces, and the edge case of non-generic derived collections

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
framework/src/Volo.Abp.ObjectMapping/Volo/Abp/ObjectMapping/ObjectMappingHelper.cs Added guard check to prevent IndexOutOfRangeException when a type implements generic collection interfaces but is not itself generic
framework/test/Volo.Abp.ObjectMapping.Tests/Volo/Abp/ObjectMapping/ObjectMappingHelper_Tests.cs Added comprehensive unit tests covering various collection type scenarios including the edge case that triggered the original bug

@maliming maliming added this to the 10.1-patch milestone Feb 22, 2026
@maliming maliming requested a review from EngincanV February 23, 2026 06:43
@EngincanV EngincanV merged commit aada21c into rel-10.1 Feb 23, 2026
3 of 5 checks passed
@EngincanV EngincanV deleted the ObjectMappingHelper-patch branch February 23, 2026 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants