Instrumenting a string
- by George Polevoy
Somewhere in C++ era i have crafted a library, which enabled string representation of the computation history.
Having a math expression like:
TScalar Compute(TScalar a, TScalar b, TScalar c)
{
return ( a + b ) * c;
}
I could render it's string representation:
r = Compute(VerbalScalar("a", 1), VerbalScalar("b", 2), VerbalScalar("c", 3));
Assert.AreEqual(9, r.Value);
Assert.AreEqual("(a+b)*c==(1+2)*3", r.History );
C++ operator overloading allowed for substitution of a simple type with a complex self-tracking entity with an internal tree representation of everything happening with the objects.
Now i would like to have the same possibility for NET strings, only instead of variable names i would like to see a stack traces of all the places in code which affected a string.
And i want it to work with existing code, and existing compiled assemblies.
Also i want all this to hook into visual studio debugger, so i could set a breakpoint, and see everything that happened with a string.
Which technology would allow this kind of things?
I know it sound like an utopia, but I think visual studio code coverage tools actually do the same kind of job while instrumenting the assemblies.