Searching for text in an Object watch window in visual studio

落花浮王杯 提交于 2019-12-30 07:54:46

问题


I am using visual studio 2010. I have set a breakpoint and added a watch on a complex object with very deep hierarchy. I was wondering if there was any quick way to search this object tree for a particular string I want. Either as a property/value/method etc. In other words, I just want to say "Does this object have anything like "Foo" in it. I don't care what it is, just tell me if it knows about "Foo". Give me all instances of "Foo"."

For example, if I have an object containing 3 Dictionaries and 4 XML elements, when I break and add watch on the object and search for "Foo", I want to find out that list 2 has a string with "Foo", List 3 has an Object "Bar" which has property "Foo" and XMLElement 1 has a child "Foo"

Is there any powerpack plugin, commercial plugin or some other extension of visual studio that would let me do this?

To give you some context. I am evaluating various PDF parsing components to parse various PDFs. I am trying to extract certain custom tags, pdf content and various other artifacts etc. While doing this, once the pdf is read and parsed, it would be nice to search the object and say something like does this know anything about the text "My Signature"... hmm.. nope. Ok. Lets call this "ConvertToHTML" method to get object B. Does object B know anything about "My Signature" etc.

Any help would be greatly appreciated.


回答1:


Visual Studio 2019

This is now natively supported in Visual Studio 2019

Searching for objects and properties in the Watch, Autos, and Locals Window by Leslie Richardson

OZ Code

There is also a commercial Visual Studio Extension called OzCode which has lots of debugging experience enhancements including search:




回答2:


One suggestion would be to serialize the whole object and do a regex search on the serialized string.



来源:https://stackoverflow.com/questions/3921681/searching-for-text-in-an-object-watch-window-in-visual-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!