Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

NonViewComponentAttribute #5226

Closed
ivaylokenov opened this issue Sep 3, 2016 · 3 comments
Closed

NonViewComponentAttribute #5226

ivaylokenov opened this issue Sep 3, 2016 · 3 comments

Comments

@ivaylokenov
Copy link
Contributor

Currently if I have the following class in the project:

public class BaseViewComponent
{
    // nothing interesting here, continue reading
}

I will receive an exception from the view component descriptor collection provider that the above class is missing Invoke or InvokeAsync method. I can easily fix the issue by making the class abstract but since there are NonControllerAttribute and NonActionAttribute maybe it will be useful to have NonViewComponentAttribute.

@rynowak
Copy link
Member

rynowak commented Sep 6, 2016

/cc @Eilon this is probably something it wouldn't hurt to add

@javiercn
Copy link
Member

javiercn commented Sep 8, 2016

I believe NonViewComponent as described here might introduce an inconsistency with the behavior for NonController. NonController marks everything in the hierarchy as not a controller. I'm not sure what the convention for view components is, but given that BaseViewComponent is being picked up, I tend to think its not compatible with the controller one. This is just something to factor in.

@ryanbrandenburg
Copy link
Contributor

I think @javiercn is right here, we'd want it to behave the same for a hypothetical NonViewComponentAttribute as it does for NonControllerAttribute, so the solution to your problem is, as you said, mark it abstract like we do here. That said I think it's perfectly reasonable to add a NonViewComponentAttribute seeing as it seems to be the pattern.

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

5 participants