Skip to content

Conversation

@fdoyon
Copy link
Contributor

@fdoyon fdoyon commented Dec 8, 2019

What kind of change does this PR introduce?
This is a feature update that allows users to override DefaultViewLocator.ViewModelToViewFunc if they are using custom naming conventions.

What is the current behavior?
Currently the users have to copy/paste the source of DefaultViewLocator and then change their ViewModelToViewFunc implementation. This is dangerous because if the logic of DefaultViewLocator changes, the copy-pasted code won't be able to carry the feature.

What is the new behavior?
Allow users to get a reference to the locator thusly:

var viewLocator = Locator.Current.GetService<IViewLocator>() as DefaultViewLocator;
viewLocator.ViewModelToViewFunc = x => x.Replace("ViewModel", "MyViewModel");

What might this PR break?
nothing

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Other information:
Discussed with @anaisbetts on slack.

@dnfclas
Copy link

dnfclas commented Dec 8, 2019

CLA assistant check
All CLA requirements met.

@fdoyon fdoyon marked this pull request as ready for review December 8, 2019 07:40
@fdoyon fdoyon requested a review from a team December 8, 2019 07:40
@fdoyon
Copy link
Contributor Author

fdoyon commented Dec 8, 2019

@RLittlesII
Copy link
Member

This isn't an unrelated test. These tests verify changes to the public API of the code. You changing from internal to public changes the API surface so the test failed. The api approval change should be uploaded to the artifacts of the build so you can see the difference between the old API surface and the new API surface. You should also be able to this to reproduce this locally running .\build.ps1 --t=Test

@RLittlesII RLittlesII changed the title DefaultViewLocator now public for users to override ViewModelToViewFunc feature: DefaultViewLocator now public for users to override ViewModelToViewFunc Dec 8, 2019
@glennawatson
Copy link
Contributor

Install a diff program like beyondcompare and it should be easy to modify with the API changes.

@glennawatson
Copy link
Contributor

You can copy .received.txt to .approved.txt -- that might get around your current issues.

@fdoyon
Copy link
Contributor Author

fdoyon commented Dec 10, 2019

Thanks - now the winforms tests are crashing - I don't have a windows machine to test on I am afraid.

@glennawatson
Copy link
Contributor

We'll do the rest for you. Thanks for getting it this far.

@codecov
Copy link

codecov bot commented Dec 13, 2019

Codecov Report

Merging #2275 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2275   +/-   ##
=======================================
  Coverage   55.32%   55.32%           
=======================================
  Files         113      113           
  Lines        4334     4334           
  Branches      660      660           
=======================================
  Hits         2398     2398           
  Misses       1771     1771           
  Partials      165      165
Impacted Files Coverage Δ
src/ReactiveUI/View/DefaultViewLocator.cs 96.61% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0dd8f2c...46884e3. Read the comment docs.

@RLittlesII
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@glennawatson glennawatson merged commit 858ef01 into reactiveui:master Dec 15, 2019
@lock lock bot locked and limited conversation to collaborators Apr 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants