byme8 / ZeroIoC

ZeroIoC is reflectionless IoC Container for C#
MIT License
44 stars 5 forks source link

ZeroIoC.ServiceIsNotRegistered: 'Type ZeroIocTest.IUserService is missing in resolver #2

Closed ekalchev closed 2 years ago

ekalchev commented 2 years ago

I am getting this exception with the following registration code

public partial class Container : ZeroIoCContainer
    {
        protected override void Bootstrap(IZeroIoCContainerBootstrapper bootstrapper)
        {
            bootstrapper.AddSingleton<Helper>();
            bootstrapper.AddSingleton<IUserService, UserService>();
            bootstrapper.AddScoped<IUserService, UserService>();
        }
    }

Generated code


public Container()
        {
          Resolvers.Add(typeof(global::ZeroIocTest.Helper), new SingletonResolver<ZeroIocTest_HelperCreator, global::ZeroIocTest.Helper>());

        }
byme8 commented 2 years ago

The registration of multiple implementations is not supported at the moment. There were had plans for it, but I decided to keep it simple and postponed the feature.

I guess will add a compilation error with an explanation for such a case to avoid misunderstanding. Maybe in the future, I will work on it.

byme8 commented 2 years ago

Pushed version 0.3.0. It has an error message that explains that there is no support for multiple implementations,