Skip to content

fix: stackoverflow on nullable readonly existing target#2086

Merged
latonz merged 2 commits into
riok:mainfrom
faddiv:bugfix/stackoverflow-on-nullable
Dec 26, 2025
Merged

fix: stackoverflow on nullable readonly existing target#2086
latonz merged 2 commits into
riok:mainfrom
faddiv:bugfix/stackoverflow-on-nullable

Conversation

@faddiv

@faddiv faddiv commented Dec 26, 2025

Copy link
Copy Markdown
Contributor

Fix stackoverflow on nullable readonly existing target

Description

This PR fixes the stack overflow exception for nullable, readonly existing target mappings.

I’d also like to get your thoughts on an idea about the tests: These tests practically test the same output on different cases. Is it enough to generate a snapshot only for a single one, and just assert for the same output on the rest? I think there are too much snapsots and hard to manage. This approach can limit it.

Another thought about the bug report itself: when one of the parameters was the Task, the generator explored it deeply, which is a waste of resources. It doesn't fix the root problem, but somehow this should be limited. Since limiting this type or that couldn't really help. My idea is to limit exploring the read-only targets themselves. So if the target is read-only, then it is explored only if it is explicitly asked in some manner. WDYT?

Fixes #2078

Checklist

  • The existing code style is followed
  • The commit message follows our guidelines
  • Performed a self-review of my code
  • Hard-to-understand areas of my code are commented
  • The documentation is updated (as applicable)
  • Unit tests are added/updated
  • Integration tests are added/updated (as applicable, especially if feature/bug depends on roslyn or framework version in use)

@latonz latonz added the bug Something isn't working label Dec 26, 2025
@latonz

latonz commented Dec 26, 2025

Copy link
Copy Markdown
Contributor

I’d also like to get your thoughts on an idea about the tests: These tests practically test the same output on different cases. Is it enough to generate a snapshot only for a single one, and just assert for the same output on the rest? I think there are too much snapsots and hard to manage. This approach can limit it.

IMO we should decide on a case by case basis whether a snapshot test makes sense. In this case, since it is only about diagnostics, I prefer the fluent TestHelper assertions. They are more focused and make these tests easier to maintain. However, whenever asserting generated mapping code, I think it is simpler to use snapshot tests.

@latonz

latonz commented Dec 26, 2025

Copy link
Copy Markdown
Contributor

Another thought about the bug report itself: when one of the parameters was the Task, the generator explored it deeply, which is a waste of resources. It doesn't fix the root problem, but somehow this should be limited. Since limiting this type or that couldn't really help. My idea is to limit exploring the read-only targets themselves. So if the target is read-only, then it is explored only if it is explicitly asked in some manner. WDYT?

Yeah I think it would make sense to only try to map direct properties of the root but not explore further. Does that make sense?

@latonz latonz changed the title Fix stackoverflow on nullable readonly existing target fix: stackoverflow on nullable readonly existing target Dec 26, 2025
@latonz
latonz merged commit 0f69dce into riok:main Dec 26, 2025
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

InsufficientExecutionStackException with read-only property

2 participants