VContainer icon indicating copy to clipboard operation
VContainer copied to clipboard

Fix WithParameter does not work with property or field injection

Open piti6 opened this issue 4 years ago • 2 comments

Subject:

    public class Hoge
    {
        [Inject]
        private readonly int _hoge;
    }
    
    protected override void Configure(IContainerBuilder builder)
    {
        builder.Register<Hoge>(Lifetime.Singleton)
            .WithParameter(1234);
    }

Expected behaviour:

  • Builder should not throw any Exception

Actual result:

  • VContainerException: No such registration of type: System.Int32

piti6 avatar Mar 02 '21 20:03 piti6

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/hadashia/vcontainer/C3aFDgsTsSUnods1ZthT6hG7Qcdr
✅ Preview: https://vcontainer-git-fork-piti6-mkim-fix-parameter-does-no-1cb9c2.vercel.app

vercel[bot] avatar Mar 02 '21 20:03 vercel[bot]

When changing the behavior of the ReferectionInjector, I found that I needed to change the CodeGen mode as well. https://github.com/hadashiA/VContainer/blob/master/VContainer/Assets/VContainer/Editor/CodeGen/InjectionILGenerator.cs#L326-L362

Let me think for a moment.

hadashiA avatar Mar 15 '21 06:03 hadashiA

Transfer to #457

piti6 avatar Apr 09 '23 15:04 piti6