s0nicyouth / kmapper

Library for automated data class to data class mapping
Apache License 2.0
15 stars 3 forks source link

Added cycle detection #18

Closed s0nicyouth closed 1 year ago

s0nicyouth commented 1 year ago

@cyc1ingsir The PR adds cycle detection to the mapper. Could you please take a look at it and possibly test if it fits your needs.

cyc1ingsir commented 1 year ago

I've tested your branch with this project: https://github.com/cyc1ingsir/kmapper-examples and this mapper defintion: https://github.com/cyc1ingsir/kmapper-examples/blob/main/src/main/kotlin/com/syouth/kmapper/testload/mappers/recursiveTest/RecursiveTestMapper.kt#L27-L32

This now produces a readable error message:

./gradlew build

> Task :kspKotlin FAILED
e: [ksp] java.lang.IllegalStateException: Cyclic definition found: RecDtoPartB->List<AtoBRelationDto>->AtoBRelationDto->RecDtoPartA->List<AtoBRelationDto>
        at com.syouth.kmapper.processor.strategies.CheckCycleStrategy.invoke(CheckCycleStrategy.kt:11

:+1: