VContainer icon indicating copy to clipboard operation
VContainer copied to clipboard

BugFix: Was able to create a component with `new` keyword

Open migus88 opened this issue 4 months ago • 1 comments

When working with source generators, if you try to do something like this on a class that inherits from Component, you will receive a NotSupportedException when trying to inject it.

builder.Register<SomeMonoBehaviour>(Lifetime.Singleton);

When working with reflection injection, the creation of a component that way is allowed.

This PR aims to align the implementations and to prevent a reflection created instances of Components.

⚠️ This might be a "breaking change" for some who used this approach in their project intentionally or not (in our case it was unintentional and it was causing havoc).

migus88 avatar Aug 04 '25 06:08 migus88

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 Aug 4, 2025 6:30am

vercel[bot] avatar Aug 04 '25 06:08 vercel[bot]