Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BlockTypes in own Project. #456

Open
kenan-kajkus opened this issue Jul 23, 2021 · 5 comments
Open

BlockTypes in own Project. #456

kenan-kajkus opened this issue Jul 23, 2021 · 5 comments
Milestone

Comments

@kenan-kajkus
Copy link

I can't find a way to implement blocktypes in a separate project. The reason is that we need the blocktypes in several projects.

@HeyJoel
Copy link
Member

HeyJoel commented Jul 23, 2021

It's not documented yet, but you'll need to do a few things:

  1. Ensure your project is named in a way it can be picked up by DI: check the relevant section of the dependency injection docs
  2. Ensure any view files are marked as embedded resources
  3. Include a class in your project that implements IAssemblyResourceRegistration - this is just a marker class that the DI system looks for to know if it should scan your project for embedded resources.
  4. Ensure view files are located in one of the default view block type folders, or implement your own IPageBlockTypeViewLocationRegistration if you want to namespace it under a custom path to avoid conflicts. See the page block types docs for more info.

Note that with embedded resources, files in your main project will override embedded resources in the same location in dependent projects.

@HeyJoel HeyJoel added this to the Backlog milestone Jul 23, 2021
@kenan-kajkus
Copy link
Author

I am still getting this error. Could you imagine why?
image

@HeyJoel
Copy link
Member

HeyJoel commented Jul 26, 2021

It looks like Cofoundry can find your block type classes, but not your view file. Do check points 2, 3 and 4 in my comments above.

I've updated the page block types sample project to include an example of placing block types in a separate project, along with a bit more detail in the readme.

@kenan-kajkus
Copy link
Author

Thank you so much. I messed up the namespaces part. What a rookie mistake.

@HeyJoel
Copy link
Member

HeyJoel commented Jul 26, 2021

No worries, it's more complicated than I'd like it to be and it isn't documented. I'm hopeing that the new source generators feature in .NET 6 is going to make all this a bit simpler because we can pull all this stuff in at compiletime instead of runtime, but I haven't had a chance to play around with it yet.

I'll leave this issue open as it needs documenting in the main Cofoundry docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants