Prerequisites
What happens
Okay, so if I make a new console project and copy/paste the "Complete Example" code over Program.cs, the last line to GetService() returns null.
What you expected instead
Clearly it should have returned an instance of UserService.
Minimal reproduction
Copy/paste the "Complete Example" from the top level README.md into a fresh C# Console project.
Steps to reproduce
- create new console project
- add Splat and this nuget package
- Copy/paste example
- Set breakpoint on last line
- Run/Debug
- Step over last line and see that userService is null
You can also inspect the Splat.DI.Reg.g.cs file and see that SetupIOCInternal() is empty..
Exception and stack trace
Package and version
This package via Nuget, v2.3.0
UI framework
None, this is a class library or console app
Operating system
Windows
Target framework
net10.0
Device and OS version
No response
IDE
Visual Studio 2026 18.9.3
Did this work in an earlier version?
no
Workaround
I've found that if I use using DI = Splat.SplatRegistrations; instead of using static Splat.SplatRegistrations;' and prefix all the RegisterXxx() calls with DI.` that things work. So I'm guessing this issue relates to the code generator not noticing the calls to the SplatRegistrations methods.
Additional information
I've also just tried via CLI on a Linux box--same result. This seems so fundamental that I must be doing something wrong, but I can't see what! TIA for any help (I can workaround for now) and my apologies if this is just a simple thing I've missed...
Prerequisites
What happens
Okay, so if I make a new console project and copy/paste the "Complete Example" code over Program.cs, the last line to GetService() returns null.
What you expected instead
Clearly it should have returned an instance of UserService.
Minimal reproduction
Copy/paste the "Complete Example" from the top level README.md into a fresh C# Console project.
Steps to reproduce
You can also inspect the Splat.DI.Reg.g.cs file and see that SetupIOCInternal() is empty..
Exception and stack trace
Package and version
This package via Nuget, v2.3.0
UI framework
None, this is a class library or console app
Operating system
Windows
Target framework
net10.0
Device and OS version
No response
IDE
Visual Studio 2026 18.9.3
Did this work in an earlier version?
no
Workaround
I've found that if I use
using DI = Splat.SplatRegistrations;instead ofusing static Splat.SplatRegistrations;' and prefix all the RegisterXxx() calls withDI.` that things work. So I'm guessing this issue relates to the code generator not noticing the calls to the SplatRegistrations methods.Additional information
I've also just tried via CLI on a Linux box--same result. This seems so fundamental that I must be doing something wrong, but I can't see what! TIA for any help (I can workaround for now) and my apologies if this is just a simple thing I've missed...