Fail fast on issues with viewmodel serialization
Currently, DotVVM reports serialization issues only if an instance of a type that cannot be serialized is sent to the client. This means that a lot of issues are discovered very late.
A sample:
public class Position
{
public int X { get; set; }
public int Y { get; set; }
public Position(int x, int y)
{
X = x;
Y = y;
}
}
public class ViewModel
{
public List<Position> Positions { get; set; }
}
DotVVM currently complains about a missing parameterless constructor in Position only when the Positions list is non-empty. It would be beneficial to learn about serialization issues as soon as possible, during any request to the page at the latest.
-
The current version should support putting data into the constructor.
-
That's not easy to do, if we don't want to report false positives. We currently have don't have a way to analyze the entire object tree, and adding such analyzer would most likely report many errors which don't occur in practice. Specifically the missing constructor is only a problem if you need to deserialize the object.
-
There is the analyzer which is designed to do something like this, but it won't fail the page entirely