5

Assume an abstract model like this:

 public abstract class MyClass : BaseEntity
{
    [UIHint("File")]
    public long? DocumentFileId { get; set; }
}

The problem is Cannot resolve template 'File', while there is File.cshtml in View editor templates.

Message as shown in Visual Studio

The point is, if I don't define MyClass as an abstract class, error will be solved.

My question is, why editor template can not resolve in abstract classes, and how can I handle it?

janv8000
  • 1,569
  • 2
  • 19
  • 33
Reza Owliaei
  • 3,293
  • 7
  • 35
  • 55

3 Answers3

4

This is a bug with ReSharper that was reported almost a year ago. Doesn't look like JetBrains are in a rush to fix it.

However, it shouldn't interfere with your development other than being a nuisance.

DavidG
  • 113,891
  • 12
  • 217
  • 223
2

Another option is to suppress the warning at the class level, like this;

[SuppressMessage("ReSharper", "Mvc.TemplateNotResolved")]
public abstract class MyClass : BaseEntity
{
    // ....
Stuart Hallows
  • 8,795
  • 5
  • 45
  • 57
0

I disabled this warning in abstract classes with comments.

// Resharper 8 fails to resolve templates in abstract classes.
// https://youtrack.jetbrains.com/issue/RSRP-373171
// ReSharper disable Mvc.TemplateNotResolved
public abstract class MyAbstractClass
{
    ...
Thomas Langston
  • 3,743
  • 1
  • 25
  • 41