Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>With ReSharper you can right-click a Razor view and <em>Find Usages</em>, but you'd have to go through manually and repeat for all views (unless you can hook into ReSharper's API and automate it).</p> <p>The problem with views of course is that they're late-bound based on a convention defined in the view engine, in the case of the default <code>RazorViewEngine</code> it looks for a corresponding view in <code>~/Views/{Controller}/{Action}</code> and <code>~/Views/Shared/{Action}</code>. So it's difficult to tell at design or compile time which views, partials and templates are never used.</p> <p>You might approch it from the opposite angle: find which views are being used. Then diff this list against all views in the project, evaluate the results (manually and with ReSharper Find Usages) and confirm they're really not being used before finally removing them.</p> <p>To find the views being used you could customise the RazorViewEngine to log every time it loads a view with <code>CreateView</code> and <code>FindPartialView</code>, e.g.</p> <pre><code>public class LoggingRazorViewEngine : RazorViewEngine { protected override IView CreateView( ControllerContext controllerContext, string viewPath, string masterPath) { LogManager.GetLogger("").Debug(viewPath); return base.CreateView(controllerContext, viewPath, masterPath); } } </code></pre> <p>Configure it in global.asax.cs</p> <pre><code>ViewEngines.Engines.Clear(); ViewEngines.Engines.Add(new LoggingRazorViewEngine()); </code></pre> <p>Then extract a list of logged unique view paths to compare against your project's views. Bit of effort involved, but possibly worth if if you've got lots of unused views cluttering up the project.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload