Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Embedded views throws AmbiguousViewException #145

Closed
thecodejunkie opened this issue Jun 4, 2011 · 3 comments
Closed

Embedded views throws AmbiguousViewException #145

thecodejunkie opened this issue Jun 4, 2011 · 3 comments
Assignees
Milestone

Comments

@thecodejunkie
Copy link
Member

Recent changes to the view discovery mechanism results in embedded views throwing AmbiguousViewException. This issue has been individually confirmed by Andreas Håkansson, Robert Greyling and Roy Jacobs.

@ghost ghost assigned thecodejunkie Jun 4, 2011
@RobertTheGrey
Copy link
Contributor

Looks like my fix was for a different problem getting ambiguous views (unrelated to embedded resources), and so this problem is still there. I'm not sure how it used to work in the past, but I did a quick debug of the ResourceViewLocationProviders class and the FileSystemViewLocationProvider class.

The Resource one is correctly picking up the two view marked as embedded resources and only those, but the FileSystem one seems to pick up all files including the ones marked as embedded which means that both providers are each finding the same file at bootstrap, and so rather than being ambiguous, it's actually the same file being registered twice, once with each provider.

I presume the fix would be to stop the FileSystem provider from picking up files marked as embedded.

@thecodejunkie
Copy link
Member Author

Yep, that's exactly the cause and the fix is fairly simple too...each ViewLocationProvider returns an enumerable of ViewLocationResult instances, each symbolizing a view that was located by the view location provider. There can be multiple IViewLocationProvider implementations and Nancy will automatically identify and use them at app start. So different implementations could, intact, return a result for the same view, as we are seeing here. So the fix should probably be to add a decent equality support to the ViewLocationResult type and then have the view locator retur the distinct set of the aggregated results for the providers.

@thecodejunkie
Copy link
Member Author

Breaking changes will be

  • ResourceViewLocationProviders changing name to ResourceViewLocationProvider
  • ResourceViewLocationProvider will not be activated by default. Only one provider can be active and FileSystemViewLocationProvider is default. Overriding the in the bootstrapper will be possible

thecodejunkie added a commit that referenced this issue Jul 24, 2011
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants