I'm trying to write a debugger type proxy/surrogate for matrices and vectors in Math.NET Numerics, so the debugger shows more useful information (also in F# FSI). The type hierarchy is as follows:
Generic.Matrix<T>
Double.Matrix : Generic.Matrix<double>
Double.DenseMatrix : Double.Matrix
Non-generic proxy with closed, generic type. It also works the same way if instead of Matrix<double>
the constructor would accept a Double.Matrix
or a Double.DenseMatrix
.
public class MatrixSummary
{
public MatrixSummary(Matrix<double> matrix) { }
// ...
}
Then, decorate Double.DenseMatrix with:
[DebuggerTypeProxy(typeof(MatrixSummary))]
I'd prefer not having to implement a separate proxy for every type, so let's make it generic:
public class MatrixSummary<T> where T : ...
{
public MatrixSummary(Matrix<T> matrix) { }
// ...
}
Then, decorate Double.DenseMatrix with:
[DebuggerTypeProxy(typeof(MatrixSummary<>))]
Or maybe closed with:
[DebuggerTypeProxy(typeof(MatrixSummary<double>))]
And/or maybe also add that attribute to the base classes if needed.
None of these work e.g. when debugging Unit Tests, even though the documentation says it is supposed to work when declaring the attribute with an open generic type (i.e. MatrixSummary<>
). After all it also works fine with List<T>
etc.
Any ideas?
Related:
Make MatrixSummary
a nested class:
[DebuggerTypeProxy(typeof(Matrix<>.MatrixSummary))]
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