Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated code does not include enclosing class when referring to nested class #2880

Closed
mkjensen opened this issue Jun 9, 2022 · 5 comments · Fixed by #2888
Closed

Generated code does not include enclosing class when referring to nested class #2880

mkjensen opened this issue Jun 9, 2022 · 5 comments · Fixed by #2888
Labels
Milestone

Comments

@mkjensen
Copy link
Contributor

mkjensen commented Jun 9, 2022

MapStruct recently switched to only generating imports for top level classes (#1386). This seems to have caused some bugs that have been fixed (#2704, #2797). However, there are more bugs as captured by this issue.

Here's a small project that shows the bugs in MapStruct 1.5.1.Final and also shows that the bugs do not exist in MapStruct 1.4.2.Final: https://github.com/mkjensen/mapstruct-nested-class-bug/tree/main

Maybe there are more, I'm not sure. Although it results in generated code that is harder to read, maybe it's worth considering to use fully qualified names when referring to classes.

@mkjensen
Copy link
Contributor Author

mkjensen commented Jun 9, 2022

I have added a test for this issue to https://github.com/mkjensen/mapstruct/tree/issue-2880 (71b250d).

As this is my first endeavor into the MapStruct code, I'm not sure I will come up with a reasonable fix any time soon.

@spencercjh
Copy link

same issue.

@filiphr filiphr added this to the 1.5.2 milestone Jun 14, 2022
@filiphr filiphr added the bug label Jun 14, 2022
@filiphr
Copy link
Member

filiphr commented Jun 14, 2022

Thanks a lot for creating the test case @mkjensen. We are going to look into this asap as it is blocking people.

Perhaps we will even add a mechanism to back out of the nested types approach. In order to have a workaround for the problem.

@filiphr
Copy link
Member

filiphr commented Jun 14, 2022

@mkjensen thanks for the test case, it helped located the problem. The fix is in PR #2888

filiphr added a commit that referenced this issue Jun 18, 2022
Co-authored-by: Martin Kamp Jensen <martin.kamp.jensen@se.com>
@AbelPelser
Copy link

This issue is still present for nested enums

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants