Splat.DI.SourceGenerator
Splat.DI.SourceGenerator copied to clipboard
Use SplatRegistrations.Register with Generic
Is it possible to use SplatRegistrations like this?
It says:
ViewModelLocator.cs(64, 9): [SPLATDI001] TConcrete has more than one constructor and one hasn't been marked with DependencyInjectionConstructorAttribute
public static void RegisterWithDesign<TInterface, TDesign>(this IMutableDependencyResolver resolver)
where TDesign : TInterface, new() => RegisterWithDesign<TInterface, TInterface, TDesign>(resolver);
public static void RegisterWithDesign<TInterface, TConcrete, TDesign>(this IMutableDependencyResolver resolver)
where TDesign : TInterface, new()
{
SplatRegistrations.Register<TInterface, TConcrete>("Init");
resolver.Register<TInterface>(() =>
Design.IsDesignMode ? new TDesign() : Locator.Current.GetService<TInterface>("Init"));
}
If not; it could be a neat feature to add.
Even this is not currently working. That's a big problem.
SplatRegistrations.Register<IAppUpdateService, AppUpdateService<TSettings>>();
Be likely a change needed in the Roslyn scanning.
I'm not going to get to making this change for a little while if you get on slack at some point I could help you with the code to provide a PR.
Even this is not currently working. That's a big problem.
Hi, how do You think, is this behavior could be related: https://github.com/reactiveui/ReactiveUI/discussions/3440 ?
GitHub
Hi, I'm writing Avalonia desktop app and I have VM that looks like: public class SampleViewModel<T> : ReactiveObject, IRoutableViewModel, ISampleViewModel {...} interface ISampleViewModel...