检测字符串

发布于 2024-09-01 10:17:48 字数 681 浏览 0 评论 0原文

在 C++ 时代的某个地方,我制作了一个库,它支持计算历史的字符串表示。 有一个像这样的数学表达式:

TScalar Compute(TScalar a, TScalar b, TScalar c)
{
 return ( a + b ) * c;
}

我可以渲染它的字符串表示形式:

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++运算符重载允许用复杂的自跟踪实体替换简单类型,该实体具有对象发生的所有事情的内部树表示。

现在我希望 NET 字符串也能有同样的可能性,只是我希望看到代码中影响字符串的所有位置的堆栈跟踪,而不是变量名。

我希望它能够与现有代码和现有编译的程序集一起使用。

另外,我希望将所有这些都连接到 Visual Studio 调试器中,这样我就可以设置一个断点,并查看字符串发生的所有情况。

哪种技术可以实现这种事情?

我知道这听起来像一个乌托邦,但我认为 Visual Studio 代码覆盖工具实际上在检测程序集时做了同样的工作。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉墨 2024-09-08 10:17:48

嗯,有多种技术可以在这里受益。

一是建立您自己的日志系统来跟踪您寻求的信息。该信息列表可以通过每个计算函数传递,或者“类范围”变量可以包含该信息。这是一种更多自己动手的方法。其水平并不低。

如果您想真正深入了解字符串类,有一种方法可以反射字符串函数。这个反射器系统声称它可以与调试系统连接(尽管我还没有尝试过)。您可以尝试使用 TestDriven.NET.NET Reflector。此外,如果您使用的是 Visual Studio 2008+ Professional 或更高版本,您应该能够直接调试到 .NET 框架本身。这将使您能够看到字符串发生了什么。

如果我误解了您正在查找的问题或信息,请告诉我。我将尽我所能提供帮助。

Well, there are multiple technologies that could benefit here.

One is build your own logging system to keep track of the info you seek. This list of information could be passed through each computational function or a "class scope" variable could contain the information. This is a more do it yourself approach. Its not low level.

If you want to dig down really deep into the string class, there is a way to reflector the string functions. This reflector system claims it can link up with a debugging system (though I have not tried this). You can try using TestDriven.NET and .NET Reflector. Also if you are using Visual Studio 2008+ Professional or higher you should be able to debug directly into the .NET framework itself. This would allow you to see what is happening to the strings.

If I misunderstand the question or the info you are looking please let me know. I will try to assist in any way that I can.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文