Skip to content

Register a service class from its own attributes only - #107

Merged
ipjohnson merged 1 commit into
mainfrom
fix/nested-service-attributes
Sep 24, 2026
Merged

ipjohnson merged 1 commit into
mainfrom
fix/nested-service-attributes

Conversation

@ipjohnson

Copy link
Copy Markdown
Owner

Closes #73.

ServiceModelUtility.GetRegistrations now reads only the attribute lists of the declaration it models. Before, it read every attribute under the declaration with DescendantNodes. A service attribute on a nested class or on a factory method in a service class then added a second registration of the outer class, with the lifetime of the inner attribute. That registration was the last one, so a [SingletonService] class resolved as a new instance each time.

The nested class and the factory method keep their own registrations, as before.

Docs

This issue has no warning on docs-ste-rewrite.

Verified

🤖 Generated with Claude Code

GetRegistrations read every attribute under the class declaration. A service attribute on a
nested class or on a factory method in the class then added one more registration of the class,
with the lifetime of the inner attribute. The last registration wins, so a singleton resolved
as a transient.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@ipjohnson
ipjohnson merged commit da18e2c into main Sep 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A service attribute inside a service class adds a second registration of that class

1 participant