Repository navigation
Register a service class from its own attributes only - #107
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #73.
ServiceModelUtility.GetRegistrationsnow reads only the attribute lists of the declaration it models. Before, it read every attribute under the declaration withDescendantNodes. 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
NestedServiceAttributeTests, one for a nested class and one for a factory method. Both fail on main and pass with this change.dotnet csharpier check .is clean.git merge-treeshows that this branch merges cleanly with Put ExcludeFromCodeCoverage on generated members only, and hide Internal members with EditorBrowsable #104, Make [CrossWireService] compile and run for keys, every registration type, and inherited interfaces #105 and Read a module's parameters and equality from its own members, and skip modules DM0003 or DM0017 rejects #106.scripts/coverage.shorscripts/verify-packages.shlocally. CI runs both.🤖 Generated with Claude Code