Skip to content

Fix duplicate injection issue + introduce Editor tests #691

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

Merged
merged 2 commits into from
Jul 7, 2024

Conversation

in3orn
Copy link

@in3orn in3orn commented Jul 2, 2024

Addressing issue #669:
Currently if TypeAnalyzer encounters duplicate field (with the same Name) in a base class, it skips injection for this class. As a result all the following fields of a base class are not injected. It leads to unexpected runtime behaviour. There are two solutions:

  • supporting "duplicate injections" like Zenject does
  • throwing exception to give immediate feedback that Injection process will go wrong

I did the 2nd approach as it detects developer's mistakes that in most cases can be easily fixed by protected injections.

Ps. I've also introduced the Editor tests. Is there any reason why most tests have to be run in a Playmode? If you like I can tweak & merge my test with others related to the TypeAnalyzer. Just wanted to know the approach :)

Copy link

vercel bot commented Jul 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
vcontainer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 4, 2024 7:06am

@hadashiA
Copy link
Owner

hadashiA commented Jul 2, 2024

Thanks for the PR 🙏

Ps. I've also introduced the Editor tests. Is there any reason why most tests have to be run in a Playmode? If you like I can tweak & merge my test with others related to the TypeAnalyzer. Just wanted to know the approach :)

Indeed, most may not need to be in Play mode.
However, there are tests in Play mode, so I preferred to have one test assembly rather than multiple separate ones.

Maybe we could split them up as you suggest.
However, in this PR, the .UnitTests asmdef has been added, but in fact the current .Tests is also a Unit Test, so maybe the name is a bit inappropriate?
If there are no strong opinions I think we could leave it as just Play mode, but what do you think?

@in3orn
Copy link
Author

in3orn commented Jul 2, 2024

I think we could rename VContainer.Tests to VContainer.PlayModeTests and VContainer.UnitTests to VContainer.EditModeTests. However moving DuplicateInjectionTest to VContainer.Tests is also fine for me. I can also move it to TypeAnalyzerTest if you think my fix is ok and don't want to rework the flow in that regard.

@hadashiA
Copy link
Owner

hadashiA commented Jul 4, 2024

I can also move it to TypeAnalyzerTest if you think my fix is ok and don't want to rework the flow in that regard.

I would like to treat the renaming of asmdef as a separate matter, so I would appreciate it if this PR did this.

@in3orn
Copy link
Author

in3orn commented Jul 4, 2024

Done :)

@hadashiA
Copy link
Owner

hadashiA commented Jul 7, 2024

Ok, thx!

@hadashiA hadashiA merged commit ce3e6a7 into hadashiA:master Jul 7, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants