The problem I'm facing might be stupid, but I've never encountered it, so I guess I need some help. I'm learning how to use a Debug Visualizer.
I've created one: DebuggerSide.cs
located in CarGarageVisualizer
namespace.
I wanted the type of CarGarage<T>
to be seen in this visualizer when debugging instance of this, so I've put following attributes to the class:
[DebuggerVisualizer(typeof(CarGarageVisualizer.DebuggerSide))]
[Serializable]
public class CarGarage<T>:IEnumerable<T>
where T : Car,new()
{
...
}
Now, to add first attribute I needed to add reference to CarGarageVisualizer
that contains the DebuggerSide
class. That's OK. But now, in my DebuggerSide
's overriden method Show()
I wanted to explicitly cast object gained from the objectProvider
argument to the type of CarGarage<T>
. But to be able to do this I would need to reference the CarGarageLibrary
that contains the definition of this. And as I said I can't do that, because I get the error about recursive reference.
From other post on this subject, I know it's a bad practice. But, I don't want to copy the CarGarage<T>
class to my Visualizer namespace (that would solve the problem, but I'm not sure if it's the right thing to do) unless there's not a better option.
Can anybody help me with this?
You should put the CarGarageVisualizer.DebuggerSide
in a separate library that will and can be referenced by both.
Didn't get it correctly, I think.
What about, putting the CarGarage<T>
in a separate library.
library CarGarage:
[Serializable]
public class CarGarage<T>:IEnumerable<T>
where T : Car,new()
{
...
}
library DebugVis: (uses CarGarage)
DebuggerSide....
library app: (uses CarGarage)
[DebuggerVisualizer(typeof(CarGarageVisualizer.DebuggerSide))]
public class CarGarageImpl<T> : CarGarage<T> { }