Reporter | Werner Strydom (bloudraak) |
---|---|
Created | Jan 25, 2012 12:09:00 AM |
Updated | Jan 25, 2012 12:09:00 AM |
Priority | Normal |
Type | Bug |
Fix versions | No Fix versions |
State | Submitted |
Assignee | Unassigned |
Subsystem | Code Analysis |
Affected versions | 6.1 |
Fixed in build | No Fixed in build |
Consider the following code:
ReSharper seems to have several problems with this. One is related errors being shown for ControllerBase. Its not possible for ControllerBase to be instantiated, so the fact that ReSharper expects views for its actions to exists (and reports an errors if they don't) seems incorrect. On the other hand, ReSharper does nothing to suggest that FooController and BaaController is missing views for the actions they inherit from ControllerBase.
It would be rather beneficial if ReSharper were to consider the fact that a controller is abstract (and therefore not report errors for non existent views). Further, it will be a productivity boost and ease maintenance if ReSharper considered the base classes of controllers. This allows me to have an abstract controller (such as ControllerBase) in a project called "Sample.Web.Mvc" and use it in two other projects Foo.Web.Application and Baa.Web.Application. When any new actions are added to the "root" controller, ReSharper can assist the developer in that a view needs to be created for each subclass in each MVC 3 project in the solution.
In a similar way, a warning can be displayed when I view FooController than views are missing. ReSharper can then help me to create all at once or perhaps one by one.
public abstract class ControllerBase<T> : Controller { public ActionResult Index() { return View(); } public ActionResult Details(int id) { return View(); } public ActionResult Create() { return View(); } [HttpPost] public ActionResult Create(T model) { try { // TODO: Add insert logic here return RedirectToAction("Index"); } catch { return View(); } } public ActionResult Edit(int id) { return View(); } [HttpPost] public ActionResult Edit(int id, T model) { try { // TODO: Add update logic here return RedirectToAction("Index"); } catch { return View(); } } public ActionResult Delete(int id) { return View(); } [HttpPost] [ActionName("Delete")] public ActionResult DeleteConfirm(int id) { try { // TODO: Add delete logic here return RedirectToAction("Index"); } catch { return View(); } } } public sealed class FooController : ControllerBase<Foo> { } public sealed class BaaController : ControllerBase<Baa> { }
ReSharper seems to have several problems with this. One is related errors being shown for ControllerBase. Its not possible for ControllerBase to be instantiated, so the fact that ReSharper expects views for its actions to exists (and reports an errors if they don't) seems incorrect. On the other hand, ReSharper does nothing to suggest that FooController and BaaController is missing views for the actions they inherit from ControllerBase.
It would be rather beneficial if ReSharper were to consider the fact that a controller is abstract (and therefore not report errors for non existent views). Further, it will be a productivity boost and ease maintenance if ReSharper considered the base classes of controllers. This allows me to have an abstract controller (such as ControllerBase) in a project called "Sample.Web.Mvc" and use it in two other projects Foo.Web.Application and Baa.Web.Application. When any new actions are added to the "root" controller, ReSharper can assist the developer in that a view needs to be created for each subclass in each MVC 3 project in the solution.
In a similar way, a warning can be displayed when I view FooController than views are missing. ReSharper can then help me to create all at once or perhaps one by one.