Closed peterhut closed 1 year ago
Thanks for raising this, @peterhut. That might be a bug. In theory, it should be automatic.
Tests use explicit registrations to avoid assembly scanning that would load all types from all test classes, which is a problem. There are a few tests testing assembly scanning, and I guess that scenario is not covered.
I'll look into it.
I can reproduce the issue in #522
Fixed. I'll release it as 2.0.1
.
The package is on NuGet (indexing is ongoing)
I encountered an issue when trying out an EndpointScopedViewModelFactory and kept getting the error 'Cannot convert view model to XyzViewModel. Make sure a custom view model factory is registered and that the created view model is of type XyzViewModel.'
Looking at the unit test Get_with_2_handlers_using_endpoint_scoped_view_model_factory I noticed it registered the ViewModelFactory explicitly using options.RegisterEndpointScopedViewModelFactory. Trying that it fixed the issue.
Is it necessary to always register it explicitly or is the automatic registration in ViewModelCompositionOptions for IEndpointScopedViewModelFactory not doing the right thing?