[Rider/Resharper] - Plugin Development - Resolving "Mvc.TemplateNotResolved" with plugin.



I'm developing plugin for CMS that uses “System.ComponentModel.DataAnnotations.UIHintAttribute” to configure how to display properties in website. These templates will resolve during runtime and therefor rider/resharper will throw “Cannot resolve template” errors.

Is it possible to try to resolve this template in the plugin and discard this error if it can resolve it?

For now, i would just hardcode all the possible templates that the CMS provides and then resolve based on those.

Thanks for the advice!

Official comment

Unfortunately, a plugin can't extend the resolve itself. However, it can suppress the warning using `IResolveProblemHighligter`, and if it's possible to provide custom details through an annotation, you can use `ICustomCodeAnnotationProvider` to dynamically apply an annotation to some code in your project.

Thank you for the advice.

However, I don't know how to suppress the warning, but i was able to replace the error message.

Can you me small example how to actually suppress the warning?

This is my code so far:

 public class UiHintResolveErrorHandler : IResolveProblemHighlighter
    public IHighlighting Run(IReference reference)
        if (reference.GetTreeNode() is not IReferenceExpression referenceExpression) return null;
        var value = referenceExpression.ConstantValue;
        if (value?.StringValue == "textarea")
            return new UiHintHighlighting(referenceExpression);
        return null;

    public IEnumerable<ResolveErrorType> ErrorTypes => new[]
[StaticSeverityHighlighting(Severity.ERROR,typeof(HighlightingGroupIds.CodeSmellStatic), OverlapResolve = OverlapResolveKind.UNRESOLVED_ERROR, OverloadResolvePriority = 20)]
public class UiHintHighlighting : IHighlighting

    private readonly IReferenceExpression _expression;

    public UiHintHighlighting(IReferenceExpression expression)
        _expression = expression;

    public bool IsValid() => _expression == null || _expression.IsValid();
    public DocumentRange CalculateRange() => _expression.GetHighlightingRange();

    public string ToolTip => "test";
    public string ErrorStripeToolTip => "test";



Matt Ellis Can you take a look my comment above, i need a bit more help with the IResolveProblemHighlighter.

Is there any documentation of these things? I can't seems to find any. I guess Resharper plugin docs should document these, but all pages related to this is marked as “coming soon”. 


Please sign in to leave a comment.