Splat.DI.SourceGenerator icon indicating copy to clipboard operation
Splat.DI.SourceGenerator copied to clipboard

Throw Exception if Missing Splat Registrations

Open mysteryx93 opened this issue 4 years ago • 2 comments

Using Splat for Dependency Injection, I'm noticing that if a class is initialized and there are missing registrations, it will pass null to the constructor and I won't know about it. Is there a way to make it "fail early" and tell me there's a missing registration to build the object?

mysteryx93 avatar Jan 26 '22 21:01 mysteryx93

How are you doing your splat registrations?

May be worth using the new source generator package https://www.nuget.org/packages/Splat.DependencyInjection.SourceGenerator/

glennawatson avatar Jan 26 '22 21:01 glennawatson

With Source Generator, actually.

This is a registration that caused me trouble because of a dependency that wasn't registered, was null, and would just throw a random error at runtime.

SplatRegistrations.RegisterLazySingleton<IAppPathService, AppPathService>();

mysteryx93 avatar Jan 27 '22 05:01 mysteryx93