In the new ReSharper 5.0 there is some MVC specific features for highlighting View and Controllers in views when you type them as strings.
So with ReSharper the string below called "ViewName" will get highlighted and clickable for navigation.
Html.RenderPartial("ViewName", model);
My question is if its possible to write custom patterns for custom extension methods. In my case i have a extension method called:
Html.RenderPartialIf(myCondition, "ViewName", model);
But when I do this ReSharper wont find my view. So can it be done?
Thanks.
Yes, you can do it by using ReSharper's feature called External Annotations.
Add such class to your project:
using System;
namespace JetBrains.Annotations
{
public class AspMvcViewAttribute : Attribute { }
}
And mark necessary parameters of your methods with this attribute
public static ActionResult RenderPartialIf(this HtmlHelper helper, bool contition, [AspMvcView] string viewName, object model)
{
...
}
and all set.
You can look at others ASP.NET MVC attributes in C:\Program Files (x86)\JetBrains\ReSharper\v5.0\Bin\ExternalAnnotations\System.Web.Mvc\System.Web.Mvc.Attributes.xml
file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With