Add WithAttributedMetadata for individual registrations - #22
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #22 +/- ##
===========================================
+ Coverage 54.54% 56.52% +1.97%
===========================================
Files 4 4
Lines 66 69 +3
Branches 23 24 +1
===========================================
+ Hits 36 39 +3
Misses 14 14
Partials 16 16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
tillig
force-pushed
the
feature/attributed-metadata-single-registration
branch
from
August 14, 2026 20:16
51a438e to
6971c58
Compare
Closes #11. Attributed metadata could only be opted into via assembly scanning; individual registrations had to rely on AttributedMetadataModule, which made the two registration styles inconsistent. The overload is closed over ConcreteReflectionActivatorData/ SingleRegistrationStyle rather than constrained to ReflectionActivatorData, because ScanningActivatorData derives from ReflectionActivatorData and constraints are not part of the method signature, so the latter collides with the existing scanning overload (CS0111).
tillig
force-pushed
the
feature/attributed-metadata-single-registration
branch
from
August 14, 2026 20:20
6971c58 to
38d5150
Compare
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 #11.
Rebased onto
developnow that #21 is merged; this PR is a single commit.Problem
Attributed metadata could only be opted into via assembly scanning. Individual registrations had to fall back to
AttributedMetadataModule, so the two registration styles behaved differently for no good reason.Change
One new overload, so
RegisterTypeandRegisterAssemblyTypesopt in the same way:Design note
The natural shape - an arity-3 overload constrained to
ReflectionActivatorData- does not compile.ScanningActivatorDataderives fromReflectionActivatorData, and generic constraints are not part of a method signature, so it is a duplicate of the existing scanning overload and fails withCS0111. I verified this rather than assuming it.Closing over
ConcreteReflectionActivatorData/SingleRegistrationStyleinstead sidesteps that, and is exactly whatRegisterType<T>()andRegisterType(Type)return. There is a test asserting the scanning overload still binds unambiguously.Scope
Covers reflection-based registrations, where the implementation type is known at registration time. Delegate registrations (
Register(c => ...)) have noImplementationTypeand still need the module; that limitation is documented on the method.The open question in #11
No conflict.
AttributedMetadataModuleskips metadata keys that are already present, so metadata is applied once rather than throwing on a duplicate key. Covered by a test.Verification
dotnet msbuild ./default.projclean: 22/22 tests pass on net10.0 and net8.0 (17 plus 5 new), zero warnings, packages build.dotnet format --verify-no-changesis clean.