-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Base class for ViewResult and PartialViewResult #6984
Comments
They probably could have shared a base class for consolidating a bit of code, but I don't think it would have proven very useful - at least, no one has asked for it yet. That is, where would anyone use a new As a side note, ASP.NET MVC 1-5 did have a So, if there are concrete scenarios where having a base class (or an interface, or whatever) would prove useful, we would certainly consider it. In the meantime closing this issue - we can reactivate if there are specific scenarios to consider. |
This is already a thing - all of the significant logic is shared, reusable, and extensible. |
This is not a big thing, granted, but since we (Microsoft+community) are making a fresh start, why not do it right? ViewResult and PartialViewResult and ViewResultExecutor and PartialViewResultExecutor share 99% of the code, the only difference I see (I may be wrong, though) is that ViewResultExecutor sets IsMainPage to true and PartialViewResultExecutor does not. It may be important to inspect an action result (in a filter, likely) to see if it is returning a view, in which case, a check of "context.Result is ViewResultBase" is easier than "context.Result is ViewResult || context.Result is PartialViewResult". Happy to contribute with a PR if you see value in it. |
@rjperes it isn't about right and wrong, it's a design choice. We felt that code factored by encapsulation is better than code factored by derivation. |
@Eilon: a good discussion to be held elsewhere! :-) |
@rjperes no worries, it's good to discuss these things and share thoughts! |
Since ViewResult and PartialViewResult share so much (properties and execution), why not have them inherit from a, abstract base class and just override ExecuteResultAsync, or some abstract method?
The text was updated successfully, but these errors were encountered: