Skip to content

SetupIOCInternal generated contents are empty? #328

Description

@Shane-KBT

Prerequisites

  • I have searched this repository's open and closed issues for duplicates.
  • I am using the latest stable release.

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

  1. create new console project
  2. add Splat and this nuget package
  3. Copy/paste example
  4. Set breakpoint on last line
  5. Run/Debug
  6. 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...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions