{{ message }}
Repository navigation
feat: map a view from the service locator under its own contract - #145
Merged
Merged
Conversation
- Add MapFromServiceLocator<TViewModel, TView>(contract, serviceContract). - A contracted IViewFor<T> registration was unreachable: the lookup always used no contract. - The existing overloads keep asking with no contract.
glennawatson
enabled auto-merge (squash)
September 26, 2026 11:54
|
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.




Summary
MapFromServiceLocatorcan now ask the service locator for a view under a contract, so a contractedIViewFor<T>registration is reachable.MapFromServiceLocator<TViewModel, TView>(contract, serviceContract). The mapping resolves undercontract, and asks the service locator forTViewunderserviceContract. A view not registered under that contract throwsInvalidOperationExceptionnaming the contract.MapFromServiceLocator<TViewModel, TView>(contract)still asks the service locator with no contract; its docs now point at the new overload.MapContractedViewFromServiceLocatorregisters a default and a contractedIViewFor<TodoItem>in the service locator and maps each.Why
A view model with a default view and a contracted view, both registered in the service locator as
IViewFor<T>, could not be mapped by contract:MapFromServiceLocator<T, IViewFor<T>>(contract)always returned the default registration. Passing the mapping's contract through would break code that maps a concrete view, registered with no contract, under a contract, so the service contract is a separate argument.Breaking changes
None. The change adds an overload.
How this was verified
IViewFor<T>registration mapped side by side, and the error for a missing contracted registration.Notes for the reviewer
ViewMappingBuilder.MapFromServiceLocator<TViewModel, TView>(string?, string?).Checklist