Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2
Feature: Map constructor parameters #35
Copy link
Copy link
Closed
Labels
Area: MappingRelates to one of the `ITopicMappingService` interfaces or implementations.Relates to one of the `ITopicMappingService` interfaces or implementations.Priority: 2Status 5: CompleteTask is considered complete, and ready for deployment.Task is considered complete, and ready for deployment.Type: FeatureIntroduces a major area of functionality.Introduces a major area of functionality.
Milestone
Description
Metadata
Metadata
Assignees
Labels
Area: MappingRelates to one of the `ITopicMappingService` interfaces or implementations.Relates to one of the `ITopicMappingService` interfaces or implementations.Priority: 2Status 5: CompleteTask is considered complete, and ready for deployment.Task is considered complete, and ready for deployment.Type: FeatureIntroduces a major area of functionality.Introduces a major area of functionality.
Currently, the
TopicMappingServiceexclusively maps properties, and requires an empty constructor. It would add flexibility, and especially for records, if constructor parameters could also be mapped.Challenges
There are two primary challenges with this.
Double Mapping
If a property is mapped via the constructor, how do we prevent it from being double mapped? This is especially true with records, where the constructor parameter might be used to define a property.
Order of Operations
Currently, the object is initialized, immediately added to cache, and then mapped. This would require assembling a collection of mapped values first and assigning them in unison, instead of assigning them as they're evaluated, and only then adding the object to the cache.
Circular References
Extrapolated out, the above means that topic associations might be evaluated prior to the root object(s) being created. This will introduce problems with circular references since the original topic can't be mapped until (constructor) dependencies are mapped.
Considerations
Double Mapping
IListand aren’t set to their default value—except that would likely introduce problems with properties initialized to a specific value.[DisableMapping]on the property itself to manually prevent this situation.MapProperties(). This could even be on theTopicMappingCacheEntry. That would depend on the parameter names matching their target properties.Circular References
The circular dependency issue could be addressed by limiting what annotations can be applied to parameters. Specifically, this could exclude:
[Include()], so no associations are mapped,[MapToParent], since no parent object will be available.