Currently, Jab uses runtime checks to find the correct service factory inside GetService<T>, this could be done by the Jab in compile time improving the runtime performance.
So instead of this code to all new instances when have depencies:
public T GetService<T>() => this is IServiceProvider<T> provider ? provider.GetService() : throw CreateServiceNotFoundException<T>();
Jab.Performance.Basic.Mixed.IMix1 IServiceProvider<Jab.Performance.Basic.Mixed.IMix1>.GetService()
{
Jab.Performance.Basic.Mixed.Mix1 service = new Jab.Performance.Basic.Mixed.Mix1(this.GetService<Jab.Performance.Basic.Singleton.ISingleton1>(), this.GetService<Jab.Performance.Basic.Transient.ITransient1>());
TryAddDisposable(service);
return service;
}
Update this code to avoid the this is IServiceProvider<T> runtime check.
Jab.Performance.Basic.Mixed.IMix1 IServiceProvider<Jab.Performance.Basic.Mixed.IMix1>.GetService()
{
ISingleton1 singleton1 = ((IServiceProvider<ISingleton1>)this).GetService();
ITransient1 transient1 = ((IServiceProvider<ITransient1>)this).GetService();
Jab.Performance.Basic.Mixed.Mix1 service = new Jab.Performance.Basic.Mixed.Mix1(singleton1, transient1);
TryAddDisposable(service);
return service;
}
See: #168 (comment)
Currently, Jab uses runtime checks to find the correct service factory inside
GetService<T>, this could be done by the Jab in compile time improving the runtime performance.So instead of this code to all new instances when have depencies:
Update this code to avoid the
this is IServiceProvider<T>runtime check.See: #168 (comment)